Northwoods.Go.Xml Assembly > Northwoods.Go.Xml Namespace > GoXmlTransformer Class : InheritsFromTransformer Property |
'Declaration Public Property InheritsFromTransformer As IGoXmlTransformer
public IGoXmlTransformer InheritsFromTransformer {get; set;}
Normally when you want to extend the behavior of a GoXmlWriter or a GoXmlReader, you define your own transformer inheriting from GoXmlTransformer and add it to the writer and/or the reader. You can do this for additional Type
s, or you can replace the transformer for a Type
.
Sometimes you would like to modify the behavior of a transformer but for some reason you are unable to inherit from that IGoXmlTransformer-implementing class. This property makes it easier to insert additional functionality into an existing GoXmlWriter by replacing a particular Type
's transformer with your own transformer that does some stuff and then delegates the rest of the implementation to the old transformer that had been registered for that Type
.
For example, imagine that you are using a GoXmlWriter such as GoSvgWriter
that already knows how to handle many Type
s, but you want to add some attributes and some elements to what is generated for that Type
. If you cannot easily define your own transformer class inheriting from the Type
's existing transformer class, you could do something such as the following to add information to each generated SVG element for GoSubGraph
s. public class ExtraSubGraphTransformer : GoSvgGenerator { public ExtraSubGraphTransformer() { this.TransformerType = typeof(GoSubGraph); } public override void GenerateAttributes(Object obj) { WriteAttrVal("extra", "attribute"); base.GenerateAttributes(obj); } public override void GenerateBody(Object obj) { WriteStartElement("extra"); WriteTextBody("element"); WriteEndElement(); base.GenerateBody(obj); } }
Then where you initialize the GoSvgWriter
, you can replace the transformer for GoSubGraph
with your own transformer that also makes use of the old one. GoSvgWriter w = new GoSvgWriter(); ExtraSubGraphTransformer egt = new ExtraSubGraphTransformer(); egt.InheritsFromTransformer = w.GetTransformer(typeof(GoSubGraph)); w.SetTransformer(typeof(GoSubGraph), egt); . . . more initialization and use of the writer
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