static ChoEnvironmentSettings() { ChoConfigurationManager.Refresh(); _appConfigFileWatcher = new ChoConfigurationChangeFileWatcher("AppConfigFileWatcher", ChoConfigurationManager.ApplicationConfigurationFilePath); _appConfigFileWatcher.DoNotUseGlobalQueue = true; _appConfigFileWatcher.SetConfigurationChangedEventHandler("OnEnvironmentChanged", (sender, e) => { // ChoAppFrxSettings.RefreshSection(); //ChoCommandLineParserSettings.RefreshSection(); CheckNChangeEnvironment(); }); if (ChoApplication.OnInitialize != null) { ChoApplication.OnInitialize(ChoAppFrxSettings.Me); } Environment = ChoAppFrxSettings.Me.AppEnvironment.NTrim(); _sharedEnvironmentConfigFilePath = ChoSharedEnvironmentManager.SharedEnvironmentConfigFilePath; _appFrxFilePath = ChoSharedEnvironmentManager.AppFrxFilePath; LoadSharedEnvironmentManager(); _appConfigFileWatcher.StartWatching(); }
private static void LoadSharedEnvironmentManager() { if (SharedEnvironmentManager != null) { SharedEnvironmentManager.Dispose(); } SharedEnvironmentManager = new ChoSharedEnvironmentManager(_sharedEnvironmentConfigFilePath); LoadFrxConfigPath(); if (_sharedEnvConfigFileWatcher != null) { _sharedEnvConfigFileWatcher.Dispose(); } if (!_sharedEnvironmentConfigFilePath.IsNullOrWhiteSpace()) { _sharedEnvConfigFileWatcher = new ChoConfigurationChangeFileWatcher("SharedEnvConfigFileWatcher", _sharedEnvironmentConfigFilePath); _sharedEnvConfigFileWatcher.DoNotUseGlobalQueue = true; _sharedEnvConfigFileWatcher.SetConfigurationChangedEventHandler("OnSharedEnvironmentFileChanged", (sender, e) => { if (SharedEnvironmentManager != null) { SharedEnvironmentManager.Dispose(); } SharedEnvironmentManager = new ChoSharedEnvironmentManager(_sharedEnvironmentConfigFilePath); LoadFrxConfigPath(); OnEnvironmentChanged(); }); _sharedEnvConfigFileWatcher.StartWatching(); } }
static ChoEnvironmentSettings() { _appConfigFileWatcher.DoNotUseGlobalQueue = true; _appConfigFileWatcher.SetConfigurationChangedEventHandler("OnEnvironmentChanged", (sender, e) => { //ConfigurationManager.RefreshSection("appSettings"); ChoAppFrxSettings.RefreshSection(); bool envChanged = false; string environment = ChoAppFrxSettings.Me.AppEnvironment.NTrim(); string sharedEnvironmentConfigFilePath = SharedEnvironmentConfigFilePath; if (environment != Environment) { envChanged = true; ChoApplication.Trace(true, "Environment changed from '{0}' to '{1}'.".FormatString(Environment, environment)); Environment = environment; } if (sharedEnvironmentConfigFilePath != _sharedEnvironmentConfigFilePath) { envChanged = true; ChoApplication.Trace(true, "SharedEnvironmentConfgiFilePath changed from '{0}' to '{1}'.".FormatString(_sharedEnvironmentConfigFilePath, sharedEnvironmentConfigFilePath)); _sharedEnvironmentConfigFilePath = sharedEnvironmentConfigFilePath; } if (envChanged) { LoadSharedEnvironmentManager(); OnEnvironmentChanged(); } }); Environment = ChoAppFrxSettings.Me.AppEnvironment.NTrim(); _sharedEnvironmentConfigFilePath = SharedEnvironmentConfigFilePath; LoadSharedEnvironmentManager(); _appConfigFileWatcher.StartWatching(); }