I have two applications: X and Y. X has a set of variables (stored in an object of a class), which have to be transferred to Y. I am planning to use an XML-file as a record stored on disk that can be accessed by name by both applications. X writes the data to that XML-file and Y reads it.
I thought I can use XmlSerializer (System.Xml.Serialization) to accomplish this. With XmlSerializer I can create an XML file that looks like this:
<MonsterCollection>
<Monsters>
<Monster name="a">
<Health>5</Health>
</Monster>
<Monster name="b">
<Health>3</Health>
</Monster>
</Monsters>
</MonsterCollection>
When Y reads this XML file, it does not know the actual data type of variables Health. Therefore, the original class has to be defined in both X and Y. Is there a way to store the datatypes in the XML-file, as well? In the end, I would like to accomplish something like this:
<Monster name="a" type="" help="This is a monster">
<var name="Health" type="uint16" val="5" help="Healthiness of this monster" />
</Monster>
<Monster name="b" type="" help="This is a monster">
<var name="Health" type="uint16" val="3" help="Healthiness of this monster" />
</Monster>