public void SerializeTest() { var us = new Models.Datas.UserSettings(); var content = JsonConvert.SerializeObject(us); string mainUsFilename = "mainUserSettingsTest.json"; string bakUsFilename = "bakUserSettingsTest.bak"; Stopwatch sw = new Stopwatch(); string readBak = null; sw.Restart(); File.WriteAllText(mainUsFilename, content); var readMain = File.ReadAllText(mainUsFilename); if (readMain == content) { File.WriteAllText(bakUsFilename, content); readBak = File.ReadAllText(bakUsFilename); } sw.Stop(); Console.WriteLine("Time span: " + sw.ElapsedMilliseconds); Assert.AreEqual(readBak, content); }
// Singleton need this private ctor. Settings() { userSettings = LoadUserSettings(); userSettings.Normalized(); // replace null with empty object. UpdateSpeedTestPool(); UpdateFileLoggerSetting(); janitor = new VgcApis.Libs.Tasks.LazyGuy( () => GC.Collect(), VgcApis.Models.Consts.Intervals.LazyGcDelay, 5000) { Name = "Settings.GC()", }; lazyBookKeeper = new VgcApis.Libs.Tasks.LazyGuy( SaveUserSettingsWorker, VgcApis.Models.Consts.Intervals.LazySaveUserSettingsDelay, 500) { Name = "Settings.SaveSettings", }; }
// Singleton need this private ctor. Settings() { userSettings = LoadUserSettings(); userSettings.Normalized(); // replace null with empty object. }