GoDigram for .NET Framework and .NET Core
Northwoods.Go.Xml Namespace / GoXmlBindingTransformer Class / AddBinding Method / AddBinding(String,String,GoXmlBindingFlags) Method
an XML attribute name
a .NET property name, or a sequence of properties separated by periods
GoXmlBindingFlags flags describing the nature of the binding
In This Topic
    AddBinding(String,String,GoXmlBindingFlags) Method
    In This Topic
    Associate an attribute on this transformer's element with a property value on this transformer's type of object.
    Syntax
    public void AddBinding( 
       string attrname,
       string proppath,
       GoXmlBindingFlags flags
    )

    Parameters

    attrname
    an XML attribute name
    proppath
    a .NET property name, or a sequence of properties separated by periods
    flags
    GoXmlBindingFlags flags describing the nature of the binding
    Remarks

    See AddBinding(String,String) for examples.

    This override also allow you to specify that this attribute, during consumption, defines the identifier by which a reference object may be referred to. The referred-to object is typically a child Northwoods.Go.GoObject of a Northwoods.Go.GoGroup. For example, if you add a Northwoods.Go.GoPort to your custom Northwoods.Go.GoNode class, but do not want to have a separate XML element defining and describing that port, you will still need to generate the identifier for that port so that links will be able to find that port. If your node class defines a property that refers to your extra port, you can call this method to make sure the identifier is written for the port and that reading this attribute will make sure that node's port is given that identifier. transformer.AddBinding("xport", "SpecialPort", GoXmlBindingFlags.DefinesShared)

    The order in which bindings are added determines the order in which properties are set when the attributes are consumed. Since setting some properties, such as the text string for a label, may modify the position or the location of a node, you should add the binding for a node's position or location last.

    Setting the HandlesNamedPorts property is similar to defining a shared attribute property path for each of the ports on a node that has a name, as returned by Northwoods.Go.GoGroup.FindName.

    As special cases, there are two property names that provide special behavior. For the Northwoods.Go.GoStroke, Northwoods.Go.GoLabeledLink, Northwoods.Go.GoPolygon, and Northwoods.Go.GoDrawing classes, you can bind to the "Points" property in order to get or set the array of points used to define those shapes. The "Points" property is not treated specially for objects of any other type.

    Also as a special case for node classes, the "TreeParentNode" property binding is handled as a reference to another node, where the other node is considered to be the "parent" node in a tree-structured diagram. This supports the definition of XML that only has elements for nodes, with an implicit link from a "parent" node to the node whose element includes the attribute corresponding to the "TreeParentNode" property. The TreeLinkPrototype property of this transformer provides a link that is copied when consuming such an element. The "TreeParentNode" property is not treated specially for objects that are not instances of IGoNode.

    See Also