예제 #1
0
        /// <summary>
        /// Selects the current environment using an application setting from the App.config/Web.config
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="settingName"></param>
        public static void SelectByAppSetting(this IEnvironmentsConfigurator configurator, string settingName)
        {
            string value = ConfigurationManager.AppSettings[settingName];

            if (string.IsNullOrEmpty(value))
            {
                throw new Exceptions.ConfigurationException("The application setting was not found: " + settingName);
            }

            configurator.Select(value);
        }
예제 #2
0
        /// <summary>
        /// Selects the current environment using an environment variable from the current process
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="valueName"></param>
        public static void SelectByEnvironmentVariable(this IEnvironmentsConfigurator configurator, string valueName)
        {
            string value = Environment.GetEnvironmentVariable(valueName);

            if (string.IsNullOrEmpty(value))
            {
                throw new Exceptions.ConfigurationException("The application setting was not found: " + valueName);
            }

            configurator.Select(value);
        }
예제 #3
0
 /// <summary>
 /// Selects the current environment using the local machine name
 /// </summary>
 /// <param name="configurator"></param>
 public static void SelectByMachineName(this IEnvironmentsConfigurator configurator)
 {
     configurator.Select(Environment.MachineName);
 }