Northwoods.GoWeb.Xml Assembly > Northwoods.GoWeb.Xml Namespace : GoXmlTransformer Class |
'Declaration Public MustInherit Class GoXmlTransformer Implements IGoXmlTransformer
public abstract class GoXmlTransformer : IGoXmlTransformer
When you define transformers for your application's object classes, you will want to inherit from this class. This provides standard implementations for all of the IGoXmlTransformer methods, which basically just call the same method on the base type's transformer.
To make it easier to access the Writer's and Reader's properties and methods, a number of their properties and methods are provided here also, whose implementations just delegate to the writer or reader. An instance of this class can only be used for one GoXmlWriter or GoXmlReader at a time, not for both at once.
GoBasicNode
and GoLabeledLink
.
public class SimpleXmlTransformBasicNode : GoXmlTransformer { public SimpleXmlTransformBasicNode() { this.TransformerType = typeof(GoBasicNode); this.ElementName = "node"; this.IdAttributeUsedForSharedObjects = true; } public override void GenerateAttributes(Object obj) { base.GenerateAttributes(obj); GoBasicNode n = (GoBasicNode)obj; WriteAttrVal("label", n.Text); WriteAttrVal("shapebounds", n.SelectionObject.Bounds); } public override Object Allocate() { GoBasicNode n = new GoBasicNode(); // you might want to do other common initialization here return n; } public override void ConsumeAttributes(Object obj) { base.ConsumeAttributes(obj); GoBasicNode n = (GoBasicNode)obj; n.Text = StringAttr("label", ""); n.SelectionObject.Bounds = RectangleFAttr("shapebounds", new RectangleF(100, 100, 40, 50)); } } public class SimpleXmlTransformLink : GoXmlTransformer { public SimpleXmlTransformLink() { this.TransformerType = typeof(GoLabeledLink); this.ElementName = "link"; } public override void GenerateAttributes(Object obj) { base.GenerateAttributes(obj); GoLabeledLink link = (GoLabeledLink)obj; GoNode n = link.FromNode as GoNode; WriteAttrVal("from", this.Writer.FindShared(n)); n = link.ToNode as GoNode; WriteAttrVal("to", this.Writer.FindShared(n)); GoText lab = link.MidLabel as GoText; if (lab != null) WriteAttrVal("label", lab.Text); } public override Object Allocate() { GoLabeledLink ll = new GoLabeledLink(); GoText lab = new GoText(); lab.Selectable = false; ll.MidLabel = lab; // you might want to do other common initialization here return ll; } public override void ConsumeAttributes(Object obj) { base.ConsumeAttributes(obj); GoLabeledLink link = (GoLabeledLink)obj; String fromid = StringAttr("from", null); GoBasicNode from = this.Reader.FindShared(fromid) as GoBasicNode; if (from != null) { link.FromPort = from.Port; } String toid = StringAttr("to", null); GoBasicNode to = this.Reader.FindShared(toid) as GoBasicNode; if (to != null) { link.ToPort = to.Port; } GoText lab = link.MidLabel as GoText; if (lab != null && IsAttrPresent("label")) { lab.Text = StringAttr("label", lab.Text); } } }
System.Object
Northwoods.GoWeb.Xml.GoXmlTransformer
Northwoods.GoWeb.Svg.GoSvgGenerator
Northwoods.GoWeb.Xml.GoXmlBindingTransformer
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