I am creating a fairly generic diagram control. That my client would like to use for different types of diagrams. I have created a DiagramBlock which inherits from GoTextNode, the idea is developers will inherit from that object to create their own specific node types.

I am trying to write some generic code to Save and Load the diagram create. When I save the diagram it looks like this
When I load it it looks like this
The definition of what the node should look like is in the class defined by a developer.
In my TransformNode class I have coded the GenerateAttributes ad ConsumeAttributes to set the position and size and label. Do I have to also save and reload the background and colour etc?
Am I missing a step?

That depends on whether you want that particular information to be specified in the XML file, or whether it should be the responsibility of the node class, or some combination of both.

Are you sure the proper node class is being instantiated?

How do I define which node class to instatiate.

Here is my Load.
public void Load(string diagram)
XmlDocument xmlDoc = new XmlDocument();
GoXmlReader reader = new GoXmlReader();
reader.AddTransformer(new TransformBlock());
reader.AddTransformer(new TransformLink());
reader.RootObject = this;
reader.UseDOM = false;

That’s specified by the value of GoXmlTransformer.TransformerType, which is typically initialized in the constructor, e.g.:

[code] public class TransformBlock : GoXmlTransformer {
public TransformBlock() {
this.TransformerType = typeof(Block); // where Block inherits from GoTextNode or whatever
this.ElementName = "block"; // XML element name
// if you need additional initialization of your Blocks,
// or if there is no default constructor (zero argument constructor) for Block,
// you'll need to override the Allocate method
For anyone else looking to solve the same problem. Here is the code I used to solve the problem. Thanks to Walter for the help.
public override void GenerateAttributes(Object obj)
DiagramBlock block = (DiagramBlock)obj;
WriteAttrVal("BlockType", obj.GetType());
public override object Allocate()
string BlockType = this.StringAttr("BlockType", "");
//It's a CAB application so I can use WorkSpace.BuildObject
return Workspace.BuildObject(Type.GetType(BlockType));