Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 public TimingService(IOptions <AppConfig> options)
 {
     _platform = options.Value.Platform;
 }
Ejemplo n.º 3
0
 static Runtime()
 {
     Platform       = new GenericPlatform();
     Assembly       = (typeof(Runtime)).Assembly;
     ApplicationUri = Path.GetDirectoryName(Assembly.Location);
 }