Northwoods.GoWeb.Xml Assembly > Northwoods.GoWeb.Xml Namespace > GoXmlBindingTransformer Class > AddBinding Method : AddBinding(String,String) Method |
transformer.AddBinding("label", "Text")
will generate a "label" attribute whose value is the value of the "Text" property on the object being generated. When the element is consumed, the "Text" property of the newly copied object will be set to the value of the "label" attribute.
This mechanism can handle all of the data types for which there are predefined methods in GoXmlTransformer to read and write attribute values. For example, if the data type of the property is Color
, it will read the attribute using the GoXmlTransformer.ColorAttr method and will write the attribute using the GoXmlTransformer.WriteAttrVal method.
To support access to properties that are not defined on the transformer's GoXmlTransformer.TransformerType Type, the proppath can be a "path" of properties, separated by periods. For example: transformer.AddBinding("img", "Image.Name")
where the GoXmlBindingTransformer is defined for a Northwoods.GoWeb.GoIconicNode, will read and write the value of the GoIconicNode.Image.Name
property.
As special cases, there are two property names that provide special behavior. For the Northwoods.GoWeb.GoStroke, Northwoods.GoWeb.GoLabeledLink, Northwoods.GoWeb.GoPolygon, and Northwoods.GoWeb.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
.
This mechanism has special code to handle Brush
es and Pen
s, because those types must not be modified. Instead, they are cloned, the property is set, and then the brush or pen property is set on the shape object. However, in most cases, you should bind to the Northwoods.GoWeb.GoShape.Northwoods.GoWeb.GoShape.BrushColor and perhaps other GoShape.Brush...
properties, and to the Northwoods.GoWeb.GoShape.PenColor and Northwoods.GoWeb.GoShape.PenWidth properties, since those properties can handle the cases when there is no Northwoods.GoWeb.GoShape.Brush or Northwoods.GoWeb.GoShape.Pen value.
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2