Question

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)?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top