Пример #1
0
        private void OnChangedConfig(object source, FileSystemEventArgs e)
        {
            _ = state.ConfigIsUpdatingWaitHandle.Reset();
            state.ConfigIsUpdating = true;
            if (state.SkipConfigFileReload)
            {
                state.SkipConfigFileReload = false;
                Logger.Debug("skipping config file reload, update source internal");
                return;
            }
            try
            {
                AdmConfig oldConfig = builder.Config;
                builder.Load();
                componentManager.UpdateSettings();
                UpdateEventStates();
                builder.OnConfigUpdated(oldConfig);

                // fire warden ro register/unregister enabled/disabled modules
                if (warden != null)
                {
                    warden.Fire();
                }
                Logger.Debug("updated configuration file");
            }
            catch (Exception ex)
            {
                Logger.Debug(ex, "config file load failed:");
            }
            state.ConfigIsUpdating = false;
            if (!state.ConfigIsUpdatingWaitHandle.Set())
            {
                Logger.Fatal("could not trigger reset event");
            }
        }
 protected AdmConfigBuilder()
 {
     if (instance == null)
     {
         Config           = new AdmConfig();
         LocationData     = new AdmLocationData();
         ConfigDir        = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "AutoDarkMode");
         ConfigFilePath   = Path.Combine(ConfigDir, "config.json");
         LocationDataPath = Path.Combine(ConfigDir, "location_data.json");
     }
 }