Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Savers/Xml/WarFoundryXmlArmySaver.cs @ 325:e0580a009e75
Re #324: Add saving of Race and System data to files
* Remove extra interfaces, as their replacements would be implementation specific and the break-down is now only a clean coding issue
* Strip out extra code from Army and GameSystem saver
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 12 Mar 2011 20:32:08 +0000 |
parents | 8a64b36d36b8 |
children |
line wrap: on
line diff
--- a/api/Savers/Xml/WarFoundryXmlArmySaver.cs Sat Mar 12 20:00:13 2011 +0000 +++ b/api/Savers/Xml/WarFoundryXmlArmySaver.cs Sat Mar 12 20:32:08 2011 +0000 @@ -17,52 +17,9 @@ namespace IBBoard.WarFoundry.API.Savers.Xml { - public class WarFoundryXmlArmySaver : IWarFoundryArmySaver + public class WarFoundryXmlArmySaver { - public const string ARMY_FILE_EXTENSION = ".army"; - - public bool Save(Army toSave, string savePath) - { - bool success = false; - ZipFile file = null; - - if (!savePath.EndsWith(ARMY_FILE_EXTENSION)) - { - savePath = savePath + ARMY_FILE_EXTENSION; - } - - try - { - file = ZipFile.Create(savePath); - file.BeginUpdate(); - file.Add(new StringZipEntrySource(CreateXmlString(toSave)), "data.armyx"); - file.CommitUpdate(); - success = true; - } - finally - { - if (file != null) - { - file.Close(); - } - } - - return success; - } - - public string CreateXmlString(WarFoundryObject toSave) - { - string xmlString = ""; - - if (toSave is Army) - { - xmlString = CreateArmyXmlString((Army)toSave); - } - - return xmlString; - } - - private string CreateArmyXmlString(Army toSave) + public string CreateXmlString(Army toSave) { XmlDocument doc = new XmlDocument(); XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);