Click or drag to resize
AB4D logo

ReaderSvgGetObjectsWithCustomProperties Method

Returns List of objects that have custom properties defined (only custom properties defined in Microsoft Visio are supported).

Namespace:  Ab2d
Assembly:  Ab2d.ReaderSvg (in Ab2d.ReaderSvg.dll) Version: 7.1.7295.1040
public List<Object> GetObjectsWithCustomProperties()

Return Value

Type: ListObject
List of objects that have custom properties

Every shape that is defined in Microsoft Visio can contain custom properties. When saving the drawing into svg, the custom properties are preserved and can be get with GetCustomProperties(String), GetCustomProperties(Object), GetObjectsWithCustomProperties or GetCustomPropertiesDataTable.

Every custom property has its associated object, key as string and a value. The value is not always of type string. The following types are supported: string, double, Boolean, DateTime, TimeSpan, decimal (for Currency).

GetCustomProperties method can be called with object or with string representing an object name. The method returns a Dictionary<string, object>.

Ab2d.ReaderSvg has some methods that are specialized to read additional data from svg files that were created with Microsoft Visio.

To get all objects that have custom properties defined use GetObjectsWithCustomProperties method.

To get all custom properties in a DataTable use GetCustomPropertiesDataTable method.

Ab2d.ReaderSvg also supports layers defined in Microsoft Visio. To get information about the layers use GetLayerNames or GetElementsForLayerName(String).


The following example shows how to display all the custom properties to the Output window.

Ab2d.ReaderSvg myReaderSvg;

myReaderSvg = new Ab2d.ReaderSvg();
Viewbox myDiagram = myReaderSvg.Read(@"c:\myDiagram.svg");

// NOTE:
// When SvgViewbox or SvgDrawing is used in XAML to read the svg file,
// use its InnerReaderSvg property to get the ReaderSvg object.

// To get all custom properties as a DataTable use GetCustomPropertiesDataTable method:
// DataTable svgData = myReaderSvg.GetCustomPropertiesDataTable();

// Get all objects that have custom properties defined
List<object> objectsList = myReaderSvg.GetObjectsWithCustomProperties();

foreach (object oneObject in objectsList)
    string objectName;

    // First display the object name
    if (oneObject is FrameworkElement)
        objectName = ((FrameworkElement)oneObject).Name;
        objectName = "Unknown";

    System.Diagnostics.Debug.WriteLine("Object name: " + objectName);

    // Get custom properties dictionary for current object
    Dictionary<string, object> customProperties;
    customProperties = myReaderSvg.GetCustomProperties(oneObject);

    // Display its keys and values
    foreach (KeyValuePair<string,object> oneProperty in customProperties)
        System.Diagnostics.Debug.WriteLine(string.Format("  {0}: {1}", oneProperty.Key, oneProperty.Value));

See Also