G
Guest
I am looking for a way to determine in RunTime if a given object is Xml
Serializable (short of trying to serialize it to xml and catching the
exception).
Is this possible?
Since an object must have a Default Constructor to be XmlSerializable I have
tried something like:
Type valueType = aRandomObject.GetType();
bool isXmlSerializable = valueType.IsClass && !valueType.IsValueType
? valueType.GetConstructor(new Type[]{}) != null : true;
but this is not correct. Am I on the right track or missing something
obvious...?
Any ideas?
Thanks in advance
Tim
Serializable (short of trying to serialize it to xml and catching the
exception).
Is this possible?
Since an object must have a Default Constructor to be XmlSerializable I have
tried something like:
Type valueType = aRandomObject.GetType();
bool isXmlSerializable = valueType.IsClass && !valueType.IsValueType
? valueType.GetConstructor(new Type[]{}) != null : true;
but this is not correct. Am I on the right track or missing something
obvious...?
Any ideas?
Thanks in advance
Tim