Mercurial > repos > IBDev-IBBoard.WarFoundry.API
changeset 323:8a64b36d36b8
Re #324: Add saving of Race and System data to files
* As per GameSystem changes for using existing code:
* Make XML creation method public
* Make sure we're encoding in UTF-8
* Implement saving method for Army
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 09 Mar 2011 20:59:34 +0000 |
parents | 3e9b0603afad |
children | e09a8d9c95f6 |
files | api/Savers/Xml/WarFoundryXmlArmySaver.cs api/Savers/Xml/WarFoundryXmlFileSaver.cs |
diffstat | 2 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Savers/Xml/WarFoundryXmlArmySaver.cs Wed Mar 09 20:32:08 2011 +0000 +++ b/api/Savers/Xml/WarFoundryXmlArmySaver.cs Wed Mar 09 20:59:34 2011 +0000 @@ -50,7 +50,7 @@ return success; } - private string CreateXmlString(WarFoundryObject toSave) + public string CreateXmlString(WarFoundryObject toSave) { string xmlString = ""; @@ -65,7 +65,7 @@ private string CreateArmyXmlString(Army toSave) { XmlDocument doc = new XmlDocument(); - XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", null, null); + XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(declaration); XmlSchema schema = new XmlSchema(); schema.Namespaces.Add("", "http://ibboard.co.uk/warfoundry/army");
--- a/api/Savers/Xml/WarFoundryXmlFileSaver.cs Wed Mar 09 20:32:08 2011 +0000 +++ b/api/Savers/Xml/WarFoundryXmlFileSaver.cs Wed Mar 09 20:59:34 2011 +0000 @@ -38,7 +38,7 @@ zipStream.Write(bytes, 0, bytes.Length); } - public byte[] GetObjectBytes (WarFoundryLoadedObject obj) + public byte[] GetObjectBytes(WarFoundryLoadedObject obj) { string xmlString = ""; @@ -46,21 +46,30 @@ { xmlString = GetGameSystemString((GameSystem)obj); } + else if (obj is Army) + { + xmlString = GetArmyString((Army)obj); + } return StringManipulation.StringToBytes(xmlString); } - - public string GetGameSystemString (GameSystem obj) + + public string GetGameSystemString(GameSystem obj) { return new WarFoundryXmlGameSystemSaver().CreateXmlString(obj); - } + } + public string GetArmyString(Army obj) + { + return new WarFoundryXmlArmySaver().CreateXmlString(obj); + } + private string GetZipEntryName(WarFoundryLoadedObject obj) { return obj.ID + GetFileExtension(obj); } - public string GetFileExtension (WarFoundryLoadedObject obj) + public string GetFileExtension(WarFoundryLoadedObject obj) { string ext = "";