public void SerializingTestChar()
        {
            var Should  = TestHelper.CreateTestChar();
            var Current = CharHolderIO.Deserialize(SharedIO.Serialize(Should));

            TestHelper.CompareCharHolder(Should, Current);
        }
        public void SerializingSTDChar()
        {
            var Should = CharHolderGenerator.CreateCharWithStandardContent();
            var Is     = CharHolderIO.Deserialize(SharedIO.Serialize(Should));

            TestHelper.CompareCharHolder(Should, Is);
        }
        public void SerializingFileChar()
        {
            var    FileContent = File.ReadAllText(Environment.CurrentDirectory + @"\assets\Flash.SRHChar");
            var    Expected    = CharHolderIO.Deserialize(FileContent);
            string fileContent = SharedIO.Serialize(Expected);
            var    Actual      = CharHolderIO.Deserialize(fileContent);

            TestHelper.CompareCharHolder(Expected, Actual);
        }
Esempio n. 4
0
 private static async void SaveExtern(CharHolder myChar)
 {
     try
     {
         SharedIO.Save(myChar, new FileInfo(Path.Combine((await SharedIO.CurrentIO.PickFolder()).FullName, myChar.FileInfo.Name)));
     }
     catch (Exception)
     {
         Log.Write(AppResources.Error_FileExportFail, true);
     }
 }
Esempio n. 5
0
 private static void SaveIntern(CharHolder myChar)
 {
     try
     {
         SharedIO.SaveAtCurrentPlace(myChar);
         Log.Write(AppResources.Info_Success_Import, true);
     }
     catch (Exception)
     {
         Log.Write(AppResources.Error_Import, true);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Try to save current char at unhandled exception
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        public static void App_UnhandledException(string Message, Exception ex)
        {
#if DEBUG
            System.Diagnostics.Debug.WriteLine(ex.Message);
#endif
            Settings.LAST_SAVE_INFO = null;
            if (Model?.MainObject is IMainType Main && Main?.FileInfo is FileInfo Info)
            {
                Info.ChangeName("EmergencySave" + Info.Name);
                SharedIO.SaveAtOriginPlace(Main).Wait();
            }
            Dictionary <string, string> param = new Dictionary <string, string>
            {
                { "Message", Message },
                { "EXMessage", ex.Message },
                { "StackTrace", ex.StackTrace },
                { "InnerException", ex?.InnerException?.Message ?? "no inner exception" }
            };
            Features.Analytics.TrackEvent("App_UnhandledExceptionAsync", param);
        }
 private static void Instance_MainObjectSaved(object sender, IMainType e)
 {
     Log.Write("MainObjectSaved");
     SettingsModel.I.COUNT_SAVINGS++;
     if (SettingsModel.I.BACKUP_VERSIONING)
     {
         string FileName = (e as CharHolder)?.MakeName(true);
         try
         {
             DirectoryInfo BackUpFolder = new DirectoryInfo(Path.Combine(SharedIO.CurrentSavePath, "BackUp"));
             SharedIO.CurrentIO.CreateFolder(BackUpFolder).Wait();
             FileInfo BackUpFile = new FileInfo(Path.Combine(BackUpFolder.FullName, FileName));
             SharedIO.Save(e, BackUpFile).Wait();
         }
         catch (Exception ex)
         {
             Log.Write("Could not save BackUpChar", ex, logType: LogType.Error);
         }
     }
 }
Esempio n. 8
0
        public static async void EnteredBackground()
        {
            if (Model.MainObject != null)
            {
                try
                {
                    if (Settings.AUTO_SAVE)
                    {
                        Settings.LAST_SAVE_INFO = await SharedIO.SaveAtOriginPlace(Model.MainObject);

                        Settings.COUNT_SAVINGS++;
                    }
                    else
                    {
                        Settings.LAST_SAVE_INFO = await SharedIO.SaveAtTempPlace(Model.MainObject);
                    }
                    Settings.CHARINTEMPSTORE = true;
                }
                catch (Exception ex)
                { Log.Write("Could not EnteredBackground", ex, logType: LogType.Error); }
            }
        }
Esempio n. 9
0
        public void TestLoadAndSave_N()
        {
            AppModel.Initialize();
            SettingsModel.Initialize();
            CharHolder Char = new CharHolder();
            var        H1   = new Handlung()
            {
                Bezeichner = "Handlung1"
            };

            Char.Add(H1);
            Char.Add(new Item()
            {
                Bezeichner = "Item"
            });

            H1.Value.Connected.Add(Char.CTRLAttribut.Charisma.Value);
            H1.Value.Connected.Add(Char.CTRLItem[0].Value);

            string Ser = SharedIO.Serialize(Char);

            TestNewConnections(CharHolderIO.Deserialize(Ser));
        }
Esempio n. 10
0
 public ConsoleStream(SharedIO /*!*/ io, ConsoleStreamType consoleType)
 {
     Assert.NotNull(io);
     _consoleType = consoleType;
     _io          = io;
 }
Esempio n. 11
0
 internal ScriptIO(SharedIO io)
 {
     Assert.NotNull(io);
     SharedIO = io;
 }
Esempio n. 12
0
        private async void OpenFile(object sender, EventArgs e)
        {
            FileInfo charfile = await SharedIO.CurrentIO.PickFile(Constants.LST_FILETYPES_CHAR, "NextChar");

            switch (Device.RuntimePlatform)
            {
            case Device.Android:
                try
                {
                    LoadFileInBackgroundSynchron(new ExtendetFileInfo(charfile.FullName), (newchar) => SharedIO.SaveAtCurrentPlace(newchar));
                }
                catch (Exception ex)
                {
                    Log.Write("Error reading file", ex);
                }
                break;

            default:
                try
                {
                    await LoadFileInBackgroundAsync(new ExtendetFileInfo(charfile.FullName), (newchar) => SharedIO.SaveAtCurrentPlace(newchar));
                }
                catch (Exception ex)
                {
                    Log.Write("Error reading file", ex);
                }
                break;
            }
        }
 public static CharHolder SaveOpen(CharHolder Char)
 {
     return(CharHolderIO.Deserialize(SharedIO.Serialize(Char)));
 }