I'm stuck at some point in my understanding of how XML deserialization could help me define my classes through XML files.
Let's say I have a new XML definition file for 2 kind of monsters, like this:
<MonstersCollection>
<Monsters>
<Monster>
<MonsterName>Dragon<MonsterName>
<HitPoints>100</Hitpoints>
</Monster>
<Monster>
<MonsterName>Beast<MonsterName>
<HitPoints>75</Hitpoints>
</Monster>
</Monsters>
</MonstersCollection>
Using XML deserializer, I get a nice List with my 2 differents monsters in it and everything is fine.
But how could I easily and elegantly instantiate a new Dragon Monster or Beast Monster elsewhere?
Should I have to clone the corresponding object in the List, or is there any other way to do this?
Ultimately, I would like to be able to do something as simple as:
MonsterType monsterType = MonsterType.Dragon
Monster newMonster = new Monster(monsterType)
And have the constructor automatically populate this new object properties with the Dragon data from the XML definition file.
Any help would be greatly appreciated.