/// <summary>
        /// Add an environment to the configuration
        /// </summary>
        /// <typeparam name="TEnvironment">The environment class to add</typeparam>
        /// <param name="configurator"></param>
        /// <param name="environmentFactory">The factory method to create the environment instance</param>
        public static void Add <TEnvironment>(this EnvironmentsConfigurator configurator, Func <TEnvironment> environmentFactory)
            where TEnvironment : class, IServiceBusEnvironment
        {
            string environmentName = DefaultTypeNameConvention(typeof(TEnvironment));

            // do not collapse or 3.5 won't build
            configurator.Add(environmentName, () => environmentFactory());
        }
        /// <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 EnvironmentsConfigurator 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);
        }
        /// <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 EnvironmentsConfigurator 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);
        }
Пример #4
0
        public static IServiceBusConfigurator Environments(this IServiceBusConfigurator configurator,
                                                           Action <IEnvironmentsConfigurator> configureCallback)
        {
            var environmentsConfigurator = new EnvironmentsConfigurator();

            configureCallback(environmentsConfigurator);

            IServiceBusEnvironment environment = environmentsConfigurator.GetCurrentEnvironment();

            if (environment != null)
            {
                environment.Configure(configurator);
            }
            return(configurator);
        }
        public static void Add(this EnvironmentsConfigurator configurator, string environmentName, Action <ServiceBusConfigurator> environmentConfigurator)
        {
            var environment = new DelegateEnvironmentConfigurator(environmentConfigurator);

            configurator.Add(environmentName, () => environment);
        }
 /// <summary>
 /// Add an environment to the configuration
 /// </summary>
 /// <typeparam name="TEnvironment">The environment class to add</typeparam>
 /// <param name="configurator"></param>
 /// <param name="environment">The environment instance already created and ready to use</param>
 public static void Add <TEnvironment>(this EnvironmentsConfigurator configurator, TEnvironment environment)
     where TEnvironment : class, IServiceBusEnvironment
 {
     configurator.Add(() => environment);
 }
 /// <summary>
 /// Add an environment to the configuration
 /// </summary>
 /// <typeparam name="TEnvironment">The environment class to add</typeparam>
 /// <param name="configurator"></param>
 public static void Add <TEnvironment>(this EnvironmentsConfigurator configurator)
     where TEnvironment : class, IServiceBusEnvironment, new()
 {
     configurator.Add(() => new TEnvironment());
 }
 /// <summary>
 /// Selects the current environment using the local machine name
 /// </summary>
 /// <param name="configurator"></param>
 public static void SelectByMachineName(this EnvironmentsConfigurator configurator)
 {
     configurator.Select(Environment.MachineName);
 }