views:

236

answers:

1

Using the DataContractSerializer, I can serialize an object graph, while maintaining object references by setting "PreserveObjectReferences". This works great for most of my object graph, but there is one spot where I have to do the serialization myself. Is there any way for me to hook into the reference preservation system myself? How can I look up IDs of objects that are already in the tree? For that matter, how do I even get a handle to the serializer "in play"? I have a section of the tree that I have to build myself, but it contains cyclical parent/child realtionships.

Note: This is an alternate solution to another question I have asked. There are two paths open to me right now, so I'm trying to cover both bases until one approach proves superior to the other. I can either tap into the DataContractSerializer's pipeline through the use of a DataContractSurrogate class, or I can handle the serialization of the special case myself, in which case I have the reference preservation problem.

A: 

Hi! I'm searching for a similar answer, even though I don't need serialization - it'd be just a perfect way to do it. Anyway... I've found an article on TCP that might help you:

http://www.codeproject.com/KB/XML/yaxlib.aspx

Yaxlib seems to be a good way to serialize nearly anything and should be adaptable to your needs.

Jones111