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