(de)Serialization of a custom type
I'm using XNA/C# and I'm trying to load my level datas from an XML file.
I'm using the XmlSerializer class for that, but I can't deserialize a Vector3.
Here's how I would see Vector3(5.3, 4.5, 1.2) (de)serialized:
<Vector3>5.3, 4.5, 1.2</Vector3>
Is there any way to do that?
As far as I know, there is no option to customize serialization of an external class. For your custom classes you can implement IXmlSerializable (http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable%28v=vs.110%29.aspx). See also: http://www.codeproject.com/Articles/474453/How-to-customize-XML-serialization
You could write your custom XmlVector3 with some conversion operator: (http://msdn.microsoft.com/en-us/library/85w54y0a.aspx).