コード例 #1
0
        static async Task Main(string[] args) =>
        await GenericHost.CreateDefaultBuilder(args)
        .ConfigureLogging(logging => logging.SetMinimumLevel(LogLevel.Debug))
        .ConfigureServices((hostContext, services) =>
        {
            // options
            services.AddOptions();
            services.Configure <ConnectionStrings>(hostContext.Configuration.GetSection("ConnectionStrings"));

            // hosted service = entrypoint
            services.AddHostedService <TimerHostedService>();

            // add dependency injection
            services.AddSingleton <IFugaService, FugaService>();
        })
        .RunConsoleAsync();
コード例 #2
0
 public static IHostBuilder CreateHostBuilder(string[] args) =>
 GenericHost
 .CreateDefaultBuilder(args)
 .ConfigureAppConfiguration((context, config) => config.AddSecrets())
 .UseStartup(config => new Startup(config));