コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Settings.cs プロジェクト: jiahua90/V2RayGCon-1
        // 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",
            };
        }
コード例 #3
0
 // Singleton need this private ctor.
 Settings()
 {
     userSettings = LoadUserSettings();
     userSettings.Normalized();  // replace null with empty object.
 }