private static void LoadEnvironmentServersSettings() { System.Configuration.Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap() { ExeConfigFilename = EnvironmentSettings.GetConfigFilePath() }, ConfigurationUserLevel.None); if (configuration != null) { AppSettingsSection appSettings = configuration.AppSettings; if (appSettings != null) { EnvironmentSettings.EnvServers = appSettings.Settings.OfType <KeyValueConfigurationElement>().ToDictionary <KeyValueConfigurationElement, string, string>((Func <KeyValueConfigurationElement, string>)(s => s.Key), (Func <KeyValueConfigurationElement, string>)(s => s.Value)); } } if (EnvironmentSettings.EnvServers != null) { return; } EnvironmentSettings.EnvServers = new Dictionary <string, string>(); }
public static string GetDefaultConfigForEnvironment(EnvironmentSettings.Environments env) { string key = ((int)env).ToString() + "DefaultConfig"; string orNull = EnvironmentSettings.EnvServers.GetOrNull <string, string>(key); if (orNull != null) { return(orNull); } throw new Exception(string.Format("No '{0}' defined in {1}", (object)key, (object)EnvironmentSettings.GetConfigFilePath())); }