public static void Main(string[] args) { var configLoader = new ConfigurationLoader(); HostsConfiguration configuration = null; if (args.Length != 2) { Console.WriteLine("No environment parameters supplied"); Console.WriteLine("Should be in the format: 'dotnet run Staging UK'"); Console.WriteLine("Loading default config instead"); configuration = configLoader.Load(); } else { var environment = args[0]; var tenant = args[1]; Console.WriteLine($"Loading configuration for '{environment}' -' {tenant}'"); configuration = configLoader.Load(environment, tenant); } Console.WriteLine("\n\n------------------\nLoaded configuration is:"); Console.WriteLine($"Tests Enabled: {configuration.TestsEnabled}"); Console.WriteLine($"Tenant: {configuration.Tenant}"); Console.WriteLine($"First API: {configuration.FirstApi}"); Console.WriteLine($"Second API: {configuration.SecondApi}"); Console.WriteLine("\n\nPress enter to exit"); Console.ReadLine(); }
internal ApplicationConfiguration() { this._extensibility = new ExtensibilityConfiguration(); this.IgnoreSslErrors = true; this._customInstallers = new List <IWindsorInstaller>(); this._database = this.Register <DatabaseConfiguration>(() => new DatabaseConfiguration(this)); this._tasks = this.Register <TasksConfiguration>(() => new TasksConfiguration(this)); this._logging = this.Register <LoggingConfiguration>(() => new LoggingConfiguration(this)); this._migration = this.Register <MigrationConfiguration>(() => new MigrationConfiguration(this)); this._hosts = this.Register <HostsConfiguration>(() => new HostsConfiguration(this)); this._advanced = this.Register <AdvancedConfiguration>(() => new AdvancedConfiguration(this)); this.Register <ApplicationConfiguration>(() => this); }
internal ApplicationConfiguration() { _extensibility = new ExtensibilityConfiguration(); _database = Register(() => new DatabaseConfiguration(this)); _services = Register(() => new ServicesConfiguration(this)); _hosts = Register(() => new HostsConfiguration(this)); _tasks = Register(() => new TasksConfiguration(this)); _logging = Register(() => new LoggingConfiguration(this)); _migration = Register(() => new MigrationConfiguration(this)); _environment = Register(() => new EnvironmentConfiguration(this)); Register(() => this); }
/// <summary> /// Loads the configuration for the given environment and tenant. /// If no environment or tenant is provided, then the default local config is loaded. /// </summary> /// <param name="environment">The environment the tests should point to.</param> /// <param name="tenant">The tenant the tests should target.</param> /// <returns>The configuration to use for the tests.</returns> public HostsConfiguration Load(string environment = "", string tenant = "") { string targetJsonFile = DefaultSettingsFile; if (!string.IsNullOrWhiteSpace(environment) && !string.IsNullOrWhiteSpace(tenant)) { // Override default config with environment specific config environment = FormatEnvironment(environment); tenant = FormatTenant(tenant); targetJsonFile = $"./Config/appsettings.{environment}.{tenant}.json"; } var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(DefaultSettingsFile) .AddJsonFile(targetJsonFile) .Build(); var gitHubConfiguration = new HostsConfiguration(); configuration.GetSection("Hosts").Bind(gitHubConfiguration); return(gitHubConfiguration); }
public Worker(IOptions <HostsConfiguration> options, IPingerManager pingerManager) { _options = options.Value; _pingerManager = pingerManager ?? throw new ArgumentNullException(nameof(pingerManager)); }