コード例 #1
0
        /// <summary>
        /// Adds and configures an ASP.NET Core web application.
        /// </summary>
        /// <param name="builder">The <see cref="IHostBuilder"/> to add the <see cref="IWebHostBuilder"/> to.</param>
        /// <param name="configure">The delegate that configures the <see cref="IWebHostBuilder"/>.</param>
        /// <param name="configureWebHostBuilder">The delegate that configures the <see cref="WebHostBuilderOptions"/>.</param>
        /// <returns>The <see cref="IHostBuilder"/>.</returns>
        public static IHostBuilder ConfigureWebHost(this IHostBuilder builder, Action <IWebHostBuilder> configure, Action <WebHostBuilderOptions> configureWebHostBuilder)
        {
            if (configure is null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            if (configureWebHostBuilder is null)
            {
                throw new ArgumentNullException(nameof(configureWebHostBuilder));
            }

            // Light up custom implementations namely ConfigureHostBuilder which throws.
            if (builder is ISupportsConfigureWebHost supportsConfigureWebHost)
            {
                return(supportsConfigureWebHost.ConfigureWebHost(configure, configureWebHostBuilder));
            }

            var webHostBuilderOptions = new WebHostBuilderOptions();

            configureWebHostBuilder(webHostBuilderOptions);
            var webhostBuilder = new GenericWebHostBuilder(builder, webHostBuilderOptions);

            configure(webhostBuilder);
            builder.ConfigureServices((context, services) => services.AddHostedService <GenericWebHostService>());
            return(builder);
        }
コード例 #2
0
        public static IHostBuilder ConfigureWebHost(this IHostBuilder builder, Action <IWebHostBuilder> configure)
        {
            var webhostBuilder = new GenericWebHostBuilder(builder);

            configure(webhostBuilder);
            return(builder);
        }
コード例 #3
0
        public static IHostBuilder ConfigureWebHost(this IHostBuilder builder, Action <IWebHostBuilder> configure)
        {
            var webhostBuilder = new GenericWebHostBuilder(builder);

            configure(webhostBuilder);
            builder.ConfigureServices((context, services) => services.AddHostedService <GenericWebHostService>());
            return(builder);
        }
コード例 #4
0
        /// <summary>
        /// Adds and configures an ASP.NET Core web application.
        /// </summary>
        public static IHostBuilder ConfigureWebHost(this IHostBuilder builder, Action <IWebHostBuilder> configure, Action <WebHostBuilderOptions> configureWebHostBuilder)
        {
            if (configure is null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            if (configureWebHostBuilder is null)
            {
                throw new ArgumentNullException(nameof(configureWebHostBuilder));
            }

            var webHostBuilderOptions = new WebHostBuilderOptions();

            configureWebHostBuilder(webHostBuilderOptions);
            var webhostBuilder = new GenericWebHostBuilder(builder, webHostBuilderOptions);

            configure(webhostBuilder);
            builder.ConfigureServices((context, services) => services.AddHostedService <GenericWebHostService>());
            return(builder);
        }
コード例 #5
0
 public HostingStartupWebHostBuilder(GenericWebHostBuilder builder)
 {
     _builder = builder;
 }
コード例 #6
0
 internal GenericWebHostBuilderWrapper(HostBuilder hostBuilder)
 {
     _builder     = new GenericWebHostBuilder(hostBuilder);
     _hostBuilder = hostBuilder;
 }
コード例 #7
0
 internal GenericWebHostBuilderWrapper(HostBuilder hostBuilder)
 {
     _builder     = new GenericWebHostBuilder(hostBuilder, new WebHostBuilderOptions());
     _hostBuilder = hostBuilder;
 }