public async Task Start(GenericPlatform platform, [CanBeNull] string[] args = null) { var builder = new HostBuilder() .ConfigureAppConfiguration(configureDelegate: (context, config) => { config.AddJsonFile("appsettings.json", optional: true); config.AddEnvironmentVariables(); if (args != null) { config.AddCommandLine(args); } }) .ConfigureServices(configureDelegate: (context, services) => { services.AddOptions(); services.Configure <AppConfig> (context .Configuration .GetSection("AppConfig")); services.AddHostedService <TimingService> (); services.Configure <AppConfig> (options => { options.Platform = platform; }); }); await builder.RunConsoleAsync(); }
public TimingService(IOptions <AppConfig> options) { _platform = options.Value.Platform; }
static Runtime() { Platform = new GenericPlatform(); Assembly = (typeof(Runtime)).Assembly; ApplicationUri = Path.GetDirectoryName(Assembly.Location); }