コード例 #1
0
        public CustomHost()
        {
            _host = new HostBuilder()
                    .ConfigureHostConfiguration(configHost =>
            {
                configHost.SetBasePath(Directory.GetCurrentDirectory());
                configHost.AddJsonFile("hostsettings.json", optional: true);
                configHost.AddEnvironmentVariables(prefix: "PREFIX_");
            })
                    .ConfigureAppConfiguration((hostContext, config) =>
            {
                config.AddEnvironmentVariables();
                config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
                config.AddJsonFile(
                    $"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json",
                    optional: true);
            })
                    .ConfigureServices((hostContext, services) =>
            {
                var config = new SfConfig();
                hostContext.Configuration.Bind("Salesforce", config);
                services.AddSingleton(config);

                services.AddHostedService <HttpServer>();
            })
                    .UseConsoleLifetime()
                    .Build();
        }
コード例 #2
0
 public HttpServer(
     HostBuilderOptions hostOptions,
     SfConfig config,
     IApplicationLifetime applicationLifetime)
 {
     _hostOptions         = hostOptions;
     _config              = config;
     _applicationLifetime = applicationLifetime;
 }
コード例 #3
0
 public HttpServer(SfConfig config)
 {
     _config = config;
 }