Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Factories/Xml/WarFoundryXmlFactory.cs @ 11:5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
* Add "add unit type" and "add equipment" methods to Race
* Deprecate old "set unit types" and "set equipment" methods on Race
* Update WarFoundryXmlFactory to use new methods
* Create DuplicateItemException for later use
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 18 Jan 2009 16:24:03 +0000 |
parents | 607c3232d689 |
children | ac232763858b |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlFactory.cs Sun Jan 04 20:43:36 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs Sun Jan 18 16:24:03 2009 +0000 @@ -238,13 +238,11 @@ XmlNode elem = GetExtraData(race); XmlNode colNode = elem.FirstChild; - - Dictionary<string, UnitType> unitTypes = new Dictionary<string, UnitType>(); - + foreach (XmlElement node in colNode.ChildNodes) { UnitType type = CreateUnitTypeFromElement(node, race, race.GameSystem); - unitTypes.Add(type.ID, type); + race.AddUnitType(type); } colNode = colNode.NextSibling; @@ -258,23 +256,18 @@ colNode = colNode.NextSibling; } - - Dictionary<string, EquipmentItem> raceEquipment = new Dictionary<string, EquipmentItem>(); - + if (colNode!=null && colNode.Name == WarFoundryXmlElementName.RACE_EQUIPMENT_ITEMS_ELEMENT.Value) { foreach (XmlElement node in colNode.ChildNodes) { EquipmentItem item = CreateEquipmentItemFromElement(node, race); - raceEquipment.Add(item.ID, item); + race.AddEquipmentItem(item); } } Dictionary<string, Ability> raceAbilities = new Dictionary<string, Ability>(); //TODO: Load abilities - - race.SetUnitTypes(unitTypes); - race.SetEquipmentItems(raceEquipment); race.SetAbilities(raceAbilities); race.SetAsFullyLoaded(); LogNotifier.DebugFormat(GetType(), "Completed loading of Race with ID {0}", race.Name);