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

Answers


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


Need Your Help

Executing an action by an AJAX request DNN MVC

jquery json asp.net-mvc dotnetnuke

Another problem occured in my DNN MVC development journey. I am wondering whether this is a bug/missing feature of I've made a mistake.

Can OpenLaszlo Use JavaScript Libraries like JQuery and PrototypeJS?

javascript jquery prototypejs openlaszlo

I have been looking at OpenLaszlo and observed that scripting in the client is implemented in JavaScript. Does this mean it is possible to use libraries like JQuery and PrototypeJS ?