/// <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 IEnvironmentsConfigurator 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 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); }
/// <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); }
public static void Add(this IEnvironmentsConfigurator configurator, string environmentName, Action <IServiceBusConfigurator> 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 IEnvironmentsConfigurator 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 IEnvironmentsConfigurator 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 IEnvironmentsConfigurator configurator) { configurator.Select(Environment.MachineName); }