public void TestIfSavingAndLoadingWorks()
        {
            var tempFile = Path.GetTempFileName();

            var settings = new BuildMonitorSettings(Guid.NewGuid().ToString());

            settings.Add("Test1", "02fdb4e0-fa5d-472a-918a-fc02c48b11a8");
            settings.Add("Test2", new List <String> {
                "Item1", "Item2"
            });
            //settings.Add("Test3", new List<IBuildDefinition> { GetTestBuildDefinition(1), GetTestBuildDefinition(2) });

            var container = new SettingsContainer <BuildMonitorSettings>();

            container.Add(settings);

            container.Save(tempFile);

            var loadedContainer = SettingsContainer <BuildMonitorSettings> .Load(tempFile);

            Assert.IsNotNull(loadedContainer);
            Assert.AreEqual(container.Count, loadedContainer.Count);

            var loadedSettings = loadedContainer.Single();

            Assert.IsNotNull(loadedSettings);

            Assert.AreEqual(settings.BuildProviderId, loadedSettings.BuildProviderId);
            Assert.AreEqual(settings.UniqueId, loadedSettings.UniqueId);
            Assert.AreEqual(settings.Count, loadedSettings.Count);

            foreach (var keyValuePair in settings)
            {
                var loadedValue = loadedSettings[keyValuePair.Key];
                Assert.IsNotNull(loadedValue);

                var expected = keyValuePair.Value as ICollection;
                if (expected != null)
                {
                    CollectionAssert.AreEqual(expected, loadedValue as ICollection);
                }
                else
                {
                    Assert.AreEqual(keyValuePair.Value, loadedValue);
                }
            }
        }
Example #2
0
        private void Load()
        {
            var buildSettings       = "buildMonitorSettings.json";
            var generalSettingsJson = "generalSettings.json";

#if DEBUG
            buildSettings       = "buildMonitorSettings_debug.json";
            generalSettingsJson = "generalSettings_debug.json";
#endif

            this.buildMonitorSettingsFilePath = Path.Combine(Consts.ApplicationUserProfileFolder, buildSettings);
            this.generalSettingsFilePath      = Path.Combine(Consts.ApplicationUserProfileFolder, generalSettingsJson);

            BuildMonitorSettingsContainer = SettingsContainer <BuildMonitorSettings> .Load(this.buildMonitorSettingsFilePath);

            this.generalSettingsContainer = SettingsContainer <GeneralSettings> .Load(this.generalSettingsFilePath);

            if (!this.generalSettingsContainer.Any())
            {
                this.generalSettingsContainer.Add(new GeneralSettings());
            }
        }
Example #3
0
        private static async Task Setup()
        {
            TccUtils.SetAlignment();

            NoticeChecker.Init();

            TccSplashScreen.InitOnNewThread();

            if (!ToolboxMode)
            {
                UpdateManager.TryDeleteUpdater();

                SplashScreen.VM.BottomText = "Checking for application updates...";
                await UpdateManager.CheckAppVersion();
            }

            // ----------------------------
            SplashScreen.VM.Progress   = 10;
            SplashScreen.VM.BottomText = "Loading settings...";
            Settings = SettingsContainer.Load();
            WindowManager.InitSettingsWindow(); // need it in case language is not correct

            SplashScreen.VM.Progress = 20;
            Process.GetCurrentProcess().PriorityClass = Settings.HighPriority
                ? ProcessPriorityClass.High
                : ProcessPriorityClass.Normal;
            if (Settings.ForceSoftwareRendering)
            {
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            // ----------------------------
            SplashScreen.VM.Progress   = 30;
            SplashScreen.VM.BottomText = "Pre-loading databases...";
            UpdateManager.CheckDatabaseHash();
            SplashScreen.VM.Progress = 40;
            await Game.InitAsync();

            // ----------------------------
            SplashScreen.VM.Progress   = 50;
            SplashScreen.VM.BottomText = "Initializing widgets...";
            await WindowManager.Init();

            SplashScreen.VM.Progress = 60;
            StartDispatcherWatcher();

            // ----------------------------
            SplashScreen.VM.Progress   = 70;
            SplashScreen.VM.BottomText = "Checking for icon database updates...";
            _ = Task.Run(() => new IconsUpdater().CheckForUpdates());

            // ----------------------------
            SplashScreen.VM.BottomText     = "Initializing packet processor...";
            SplashScreen.VM.Progress       = 80;
            PacketAnalyzer.ProcessorReady += LoadModules;
            await PacketAnalyzer.InitAsync();

            // ----------------------------
            SplashScreen.VM.Progress   = 90;
            SplashScreen.VM.BottomText = "Starting";
            GameEventManager.Instance.SetServerTimeZone(Settings.LastLanguage);
            UpdateManager.StartPeriodicCheck();

            SplashScreen.VM.Progress = 100;
            SplashScreen.CloseWindowSafe();


            // ----------------------------
            Log.Chat($"{AppVersion} ready.");
            ReadyEvent?.Invoke();

            if (!Beta && Settings.BetaNotification && UpdateManager.IsBetaNewer())
            {
                Log.N("TCC beta available", SR.BetaAvailable, NotificationType.Success, 10000);
            }
        }