Beispiel #1
0
 public static void SerializeToFile(string fileName, ExportedBattle battle)
 {
     // Save the version for local editing.
     Directory.CreateDirectory(UiHelper.GetParentFolder(fileName));
     using (var writer = new StreamWriter(fileName))
     {
         var serial = new JsonSerializer();
         serial.Formatting = Newtonsoft.Json.Formatting.Indented;
         serial.Serialize(writer, battle);
     }
 }
Beispiel #2
0
        public static void ExportStandalone(DataTbls dataTbls, string filename)
        {
            var selectedBattleId = dataTbls.selectedBattle.battle_id;

            ExportedBattle export = new ExportedBattle()
            {
                battle   = dataTbls.battleData.GetBattle(selectedBattleId),
                fighters = dataTbls.selectedFighters,
                spirit   = dataTbls?.spiritData?.GetSpiritByName(selectedBattleId)
            };

            var unencryptedFileName = String.Format("{0}{1}", selectedBattleId, Defs.standaloneExportExtension);

            // Check whether user entered custom folder name.  If not, use standard format.
            var standalonePath = FileHelper.IsDefaultFolderDialogPath(filename) ?
                                 FileHelper.ToDefaultBattleExportFolder(filename) :
                                 filename;

            XmlHelper.SerializeToFile($"{standalonePath}\\{unencryptedFileName}", export);
        }