Serialization and Node inheritance

Hi Walter, here is the situation. I use a GraphLinksModel(Of Node, Link) where Node and Link are classes that inherit from GraphLinkModelNodeData and GraphLinkModelLinkData. But I have other kind of nodes that inherit from my class Node (for example: StreamNode, ExchangerNode).

When it comes the time to serialize the model, all nodes are converted in type Node instead of their respective type. Is there a way to serialize each node in their respective type?

What kind of serialization mechanism are you using? How did you configure it?

We use this approach:

Dim root As System.Xml.Linq.XElement = _GridDiagramModel.Save(Of GoXam.Node, GoXam.Link)(“GridDiagramModel”, “Node”, “Link”)

Did you override the GraphLinksModelNodeData.MakeXElement and LoadFromXElement methods? This makes sure that all of the needed data is written and read.

Do you call the GraphLinksModel.Load overloaded method that takes Func<XElement, NodeDataType> as allocators, rather than just the names? This lets you construct the appropriate subclass when loading.

I did not use the overloaded Load method, but now it seems to work. Thank you!