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 ReflectInsightConfig GetActiveApplicationConfig(ReflectInsightConfig appConfig, out string activeFileName) { activeFileName = AppConfigFullFileName(); if (appConfig == null) { return(null); } var externalConfigSource = appConfig.GetAttribute(".", "externalConfigSource", string.Empty); if (!string.IsNullOrWhiteSpace(externalConfigSource)) { var fullPathConfigFile = RIUtils.DetermineParameterPath(externalConfigSource); if (string.IsNullOrWhiteSpace(Path.GetDirectoryName(externalConfigSource))) { fullPathConfigFile = string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, externalConfigSource); } // just in case someone is trying to play smart by assigning the external source name // to the App Config file name, just ignore and assume the app config file only if (fullPathConfigFile.ToLower() != AppConfigFullFileName().ToLower()) { appConfig = ReadAndCreateConfigObject(fullPathConfigFile); activeFileName = fullPathConfigFile; } } return(appConfig); }
static private void OnShutdown() { try { AppDomain.CurrentDomain.ProcessExit -= OnShutdown; RIEventManager.OnConfigChange -= OnConfigFileChange; RIEventManager.DoOnShutdown(); ReflectInsight.OnShutdown(); DebugManager.OnShutdown(); RIMessageColors.OnShutdown(); RILogManager.OnShutdown(); RIListenerGroupManager.OnShutdown(); ReflectInsightConfig.OnShutdown(); TraceMethod.OnShutdown(); RITraceListener.OnShutdown(); } catch (Exception ex) { RIExceptionManager.Publish(ex, "Failed during: static ReflectInsightService.OnShutdown()"); } finally { RIExceptionManager.OnShutdown(); DebugTextLoggerManager.OnShutdown(); } }
static internal void OnShutdown() { DisposeAppConfigFileWatcher(); DisposeExternConfigFileWatcher(); FDefaultConfig = null; FAssignedConfig = null; }
private static void SetAssignedConfig(ReflectInsightConfig config) { lock (Lockobject) { FAssignedConfig = config ?? FDefaultConfig; FAssignedConfig.ConstructSubsections(); RIEventManager.DoOnConfigSettingsInitialized(FAssignedConfig); } }
/// <summary> /// Does the on configuration settings initialized. /// </summary> /// <param name="settings">The settings.</param> static internal void DoOnConfigSettingsInitialized(ReflectInsightConfig settings) { try { OnConfigSettingsInitialized?.Invoke(settings); } catch (Exception ex) { RIExceptionManager.Publish(ex, "Failed during: RIEventManager.DoOnConfigSettingsInitialized()"); } }
static ReflectInsightConfig() { Lockobject = new object(); CurrentConfigurationMode = ConfigurationMode.Application; LastConfigFullPath = string.Empty; FDefaultConfig = new ReflectInsightConfig(null); Control = new ConfigurationControl(); FAssignedConfig = null; FAppConfigFileWatcher = null; FExternConfigFileWatcher = null; IgnorePhysicalConfigChange = false; FLastFileChangeTimestamp = DateTime.MinValue; }
internal static void SetExternalConfigurationMode(XmlDocument xmlDoc) { if (xmlDoc == null) { throw new ArgumentNullException("xmlDoc"); } lock (Lockobject) { ReflectInsightConfig appConfig = new ReflectInsightConfig(xmlDoc.SelectSingleNode("configuration/insightSettings")); DisposeAppConfigFileWatcher(); DisposeExternConfigFileWatcher(); CurrentConfigurationMode = ConfigurationMode.Document; LastConfigFullPath = string.Empty; SetAssignedConfig(appConfig); } Control.ForceConfigChange(); }
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); } }
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(); } }
public void ClearExternalConfigurationMode() { ReflectInsightConfig.ClearExternalConfigurationMode(); }
public void SetExternalConfigurationMode(string externalConfigFile) { ReflectInsightConfig.SetExternalConfigurationMode(externalConfigFile); }
public void SetExternalConfigurationMode(XDocument xDoc) { ReflectInsightConfig.SetExternalConfigurationMode(xDoc); }