GoDigram for .NET Framework and .NET Core
Northwoods.Go.Xml Namespace / GoXmlBindingTransformer Class / GenerateChildAttributes Method
the GoXmlBindingTransformer being used to write the child object
In This Topic
    GenerateChildAttributes Method
    In This Topic
    This is called on the parent's GoXmlBindingTransformer for each child object, when HandlesChildren and HandlesChildAttributes are true, to allow a parent object to add attributes to each child element.
    Syntax
    protected virtual void GenerateChildAttributes( 
       object parent,
       object child,
       GoXmlBindingTransformer childtransformer
    )

    Parameters

    parent
    child
    childtransformer
    the GoXmlBindingTransformer being used to write the child object
    Remarks

    For example, this can be used to help generate a dictionary that maps key values to child objects by writing a "key" attribute value on each child object. This could also be used to store a "value" attribute value on each child object, assuming the child object itself is the key in the dictionary.

    By default this does nothing, unless HandlesSubGraphCollapsedChildren and HandlesChildAttributes are both true and this parent is a Northwoods.Go.GoSubGraph and the child is a Northwoods.Go.GoObject. If those conditions are true, this will write out saved bounds or saved path information for each child object if the subgraph is not expanded.

    Here is an example transformer for Northwoods.Go.GoSubGraph:

    GoSubGraph sg = new GoSubGraph(); ... do subgraph initialization ... GoXmlBindingTransformer st = new GoXmlBindingTransformer("subgraph", sg); st.HandlesNamedPorts = true; // generates children and consumes them by adding to the subgraph st.HandlesChildren = true; // make sure reading/writing each child calls the Generate/ConsumeChildAttributes methods st.HandlesChildAttributes = true; // actually read/write SavedBounds and SavedPath attributes on children, when collapsed st.HandlesSubGraphCollapsedChildren = true; st.AddBinding("back", "BackgroundColor"); st.AddBinding("opacity", "Opacity"); st.AddBinding("border", "BorderPen.Color"); st.AddBinding("borderwidth", "BorderPen.Width"); st.AddBinding("loc", "Location"); // SavedBounds, and SavedPaths if collapsed on each child, handled by Generate/ConsumeChildAttributes // define these AFTER defining Location binding st.AddBinding("wasexpanded", "WasExpanded"); st.AddBinding("expanded", "IsExpanded"); readerorwriter.AddTransformer(st);
    See Also