comparison api/Factories/Xml/WarFoundryXmlSaver.cs @ 106:9bf5eff0992a

Re #53: Add XML saver * Pad out some initial construction of XML for contained units
author IBBoard <dev@ibboard.co.uk>
date Mon, 17 Aug 2009 19:58:54 +0000
parents f5aec697b8ea
children c4ee96a91018
comparison
equal deleted inserted replaced
105:f5aec697b8ea 106:9bf5eff0992a
89 root.SetAttribute("id", toSave.ID); 89 root.SetAttribute("id", toSave.ID);
90 root.SetAttribute("name", toSave.Name); 90 root.SetAttribute("name", toSave.Name);
91 root.SetAttribute("system", toSave.GameSystem.ID); 91 root.SetAttribute("system", toSave.GameSystem.ID);
92 root.SetAttribute("race", toSave.Race.ID); 92 root.SetAttribute("race", toSave.Race.ID);
93 root.SetAttribute("maxPoints", toSave.MaxPoints.ToString()); 93 root.SetAttribute("maxPoints", toSave.MaxPoints.ToString());
94 XmlElement units = doc.CreateElement("units");
95 root.AppendChild(units);
96
97 foreach (Unit unit in toSave.GetUnits())
98 {
99 XmlElement unitElem = doc.CreateElement("unit");
100 unitElem.SetAttribute("id", unit.ID);
101 unitElem.SetAttribute("unitName", unit.Name);
102 unitElem.SetAttribute("unitType", unit.UnitType.ID);
103 unitElem.SetAttribute("size", unit.Size.ToString());
104
105 if (!unit.Race.Equals(toSave.Race))
106 {
107 unitElem.SetAttribute("race", unit.Race.ID);
108 }
109 }
110
94 return doc.OuterXml; 111 return doc.OuterXml;
95 } 112 }
96 } 113 }
97 } 114 }