views:

204

answers:

1

I have a use case where I am serializing objects over the wire via MSMQ (mostly strings). When I read the object off the queue I want to be able to tell if the user meant for the object to be a XML or a string. I was thinking a good way to do this would just be to check the type. If it's XmlElement than it becomes XML data otherwise it becomes string or CDATA. The reason I don't want to just check to see if the data is valid XML is that sometimes data will be provided that is supposed to be serialized as a string but is in fact valid XML. I want the caller to be able to control the de-serialization into string or XML.

Are there any types that are marked as serializable in the .NET Framework like XElement or XmlElement (both which are not marked serializable)?

+2  A: 

Why don't you just add a property to the class of the serialized object that tells you what it is? I'd propose IsXml.

Hans Passant
I could make a wrapper class... right now the class is just string and I was looking for an alternative that represented an XML element, exists in the framework already, and is serializable.
spoon16
and that's what I did. thanks for getting my brain started nobugz :)
spoon16