# HG changeset patch # User IBBoard # Date 1250539134 0 # Node ID 9bf5eff0992a9a6830b1b7807069d5813e2e0728 # Parent f5aec697b8eab65e5042f2aa2a6f6d5a7199646e Re #53: Add XML saver * Pad out some initial construction of XML for contained units diff -r f5aec697b8ea -r 9bf5eff0992a api/Factories/Xml/WarFoundryXmlSaver.cs --- a/api/Factories/Xml/WarFoundryXmlSaver.cs Mon Aug 17 19:08:44 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlSaver.cs Mon Aug 17 19:58:54 2009 +0000 @@ -91,6 +91,23 @@ root.SetAttribute("system", toSave.GameSystem.ID); root.SetAttribute("race", toSave.Race.ID); root.SetAttribute("maxPoints", toSave.MaxPoints.ToString()); + XmlElement units = doc.CreateElement("units"); + root.AppendChild(units); + + foreach (Unit unit in toSave.GetUnits()) + { + XmlElement unitElem = doc.CreateElement("unit"); + unitElem.SetAttribute("id", unit.ID); + unitElem.SetAttribute("unitName", unit.Name); + unitElem.SetAttribute("unitType", unit.UnitType.ID); + unitElem.SetAttribute("size", unit.Size.ToString()); + + if (!unit.Race.Equals(toSave.Race)) + { + unitElem.SetAttribute("race", unit.Race.ID); + } + } + return doc.OuterXml; } }