コード例 #1
0
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .UseWindowsService()         //https://csharp.christiannagel.com/2019/10/15/windowsservice/
        .ConfigureAppConfiguration((hostingContext, config) =>
        {
            config.AddJsonFile($"{AUTOUPDATER_PROCESS_EXEC}.json");
        })
        .ConfigureServices((hostContext, services) =>
        {
            IConfiguration configuration = hostContext.Configuration;

            WorkerOptions workerOptions = configuration.GetSection("WorkerOptions").Get <WorkerOptions>();
            services.AddSingleton(workerOptions);

            DeploySettings deploySettings = configuration.GetSection("DeploySettings").Get <DeploySettings>();
            services.AddSingleton(deploySettings);

            services.AddSingleton <Informer>();

            services.AddHostedService <Worker>();
        });
コード例 #2
0
 public Informer(ILogger <Informer> logger, WorkerOptions workerOptions, DeploySettings deploySettings)
 {
     _logger         = logger;
     _workerOptions  = workerOptions;
     _deploySettings = deploySettings;
 }