Example #1
0
        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();
        }
Example #2
0
        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();
            }
        }