private static void SetApplicationConfigFile() { lock (Lockobject) { DisposeExternConfigFileWatcher(); CreateAppConfigFileWatcher(); var activeFileName = (string)null; ReflectInsightConfig appConfig = ReadAndCreateConfigObject(AppConfigFullFileName()); ReflectInsightConfig activeConfig = GetActiveApplicationConfig(appConfig, out activeFileName); LastConfigFullPath = activeFileName; CurrentConfigurationMode = ConfigurationMode.Application; if (LastConfigFullPath.ToLower() != AppConfigFullFileName().ToLower()) { CurrentConfigurationMode = ConfigurationMode.ApplicationExternal; CreateExternConfigFileWatcher(LastConfigFullPath); } SetAssignedConfig(activeConfig); } }
internal static void SetExternalConfigurationMode(string externalConfigFile) { var bForceConfigChange = false; lock (Lockobject) { // if external config mode is true and the last used config file is equal to // the external config file then we already have it loaded externalConfigFile = RIUtils.DetermineParameterPath(externalConfigFile.IfNullOrEmptyUseDefault(string.Empty)); if (CurrentConfigurationMode != ConfigurationMode.External || externalConfigFile.ToLower() != LastConfigFullPath.ToLower()) { ReflectInsightConfig appConfig = ReadAndCreateConfigObject(externalConfigFile); DisposeAppConfigFileWatcher(); DisposeExternConfigFileWatcher(); CreateExternConfigFileWatcher(externalConfigFile); CurrentConfigurationMode = ConfigurationMode.External; LastConfigFullPath = externalConfigFile; SetAssignedConfig(appConfig); bForceConfigChange = true; } } if (bForceConfigChange) { Control.ForceConfigChange(); } }
private static void DoOnConfigFileChanged(FileSystemEventArgs e) { if (IgnorePhysicalConfigChange) { return; } var bDoOnConfigChange = false; lock (Lockobject) { switch (e.ChangeType) { case WatcherChangeTypes.Created: case WatcherChangeTypes.Deleted: case WatcherChangeTypes.Changed: { ReflectInsightConfig appConfig = ReadAndCreateConfigObject(e.FullPath); if (appConfig != null && appConfig.GetBaseConfigChangeAttribute("enabled", "true") == "false") { break; } bDoOnConfigChange = true; // if config mode is either ApplicationExternal or External, then do the following if (CurrentConfigurationMode == ConfigurationMode.Application || e.FullPath.ToLower() != LastConfigFullPath.ToLower()) { // Although the mode can either be Application or Application External, // the app config file is the only file that has changed if we get here. var activeFileName = (string)null; appConfig = GetActiveApplicationConfig(appConfig, out activeFileName); if (e.FullPath.ToLower() != activeFileName.ToLower()) { // this tells us that the app config is not the active config file // and/or that the last external app config is not the same as the previous external app config if (activeFileName.ToLower() != LastConfigFullPath.ToLower()) { LastConfigFullPath = activeFileName; CurrentConfigurationMode = ConfigurationMode.ApplicationExternal; CreateExternConfigFileWatcher(LastConfigFullPath); } else { // only the app config has changed but external remains the same bDoOnConfigChange = false; } } else { LastConfigFullPath = activeFileName; CurrentConfigurationMode = ConfigurationMode.Application; DisposeExternConfigFileWatcher(); } } if (bDoOnConfigChange) { SetAssignedConfig(appConfig); } } break; } } if (bDoOnConfigChange) { Control.ForceConfigChange(); } }