public Host(IServiceProvider services, IHostEnvironment hostEnvironment, PhysicalFileProvider defaultProvider, IHostApplicationLifetime applicationLifetime, ILogger <Host> logger, IHostLifetime hostLifetime, IOptions <HostOptions> options) { ThrowHelper.ThrowIfNull(services); ThrowHelper.ThrowIfNull(applicationLifetime); ThrowHelper.ThrowIfNull(logger); ThrowHelper.ThrowIfNull(hostLifetime); Services = services; _applicationLifetime = (applicationLifetime as ApplicationLifetime) !; _hostEnvironment = hostEnvironment; _defaultProvider = defaultProvider; if (_applicationLifetime is null) { throw new ArgumentException(SR.IHostApplicationLifetimeReplacementNotSupported, nameof(applicationLifetime)); } _logger = logger; _hostLifetime = hostLifetime; _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); }
public Host(IServiceProvider services, IApplicationLifetime applicationLifetime, ILogger <Host> logger, IHostLifetime hostLifetime, IOptions <HostOptions> options) { Services = services ?? throw new ArgumentNullException(nameof(services)); _applicationLifetime = (applicationLifetime ?? throw new ArgumentNullException(nameof(applicationLifetime))) as ApplicationLifetime; _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _hostLifetime = hostLifetime ?? throw new ArgumentNullException(nameof(hostLifetime)); _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); }
public Host(IServiceProvider services, IHostApplicationLifetime applicationLifetime, ILogger <Host> logger, IHostLifetime hostLifetime, IOptions <HostOptions> options) { Services = services ?? throw new ArgumentNullException(nameof(services)); _applicationLifetime = (applicationLifetime ?? throw new ArgumentNullException(nameof(applicationLifetime))) as ApplicationLifetime; if (_applicationLifetime is null) { throw new ArgumentException("Replacing IHostApplicationLifetime is not supported.", nameof(applicationLifetime)); } _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _hostLifetime = hostLifetime ?? throw new ArgumentNullException(nameof(hostLifetime)); _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); }
public Host( IServiceCollection appServices, IServiceProvider hostingServiceProvider, HostOptions options, IConfiguration config) { _applicationServiceCollection = appServices ?? throw new ArgumentNullException(nameof(appServices)); _hostingServiceProvider = hostingServiceProvider ?? throw new ArgumentNullException(nameof(hostingServiceProvider)); _options = options; _config = config ?? throw new ArgumentNullException(nameof(config)); _applicationServiceCollection.AddSingleton <IHostLifetime, ApplicationLifetime>(); _applicationServiceCollection.AddSingleton <HostedServiceExecutor>(); }
public static void Initialize(this IApplicationEnvironment hostingEnvironment, string applicationName, HostOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (string.IsNullOrEmpty(applicationName)) { throw new ArgumentException("A valid non-empty application name must be provided.", nameof(applicationName)); } hostingEnvironment.ApplicationName = applicationName; hostingEnvironment.EnvironmentName = options.Environment ?? hostingEnvironment.EnvironmentName; }