Skip to content

Commit cad9ea1

Browse files
committed
Rename WebApplication to WebHost
1 parent 0673ace commit cad9ea1

29 files changed

+583
-481
lines changed

samples/SampleStartups/StartupBlockingOnStart.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,14 @@ public void Configure(IApplicationBuilder app)
2828
// Entry point for the application.
2929
public static void Main(string[] args)
3030
{
31-
var config = WebApplicationConfiguration.GetDefault(args);
32-
33-
var application = new WebApplicationBuilder()
34-
.UseConfiguration(config)
31+
var host = new WebHostBuilder()
32+
.UseDefaultConfiguration(args)
3533
.UseStartup<StartupBlockingOnStart>()
3634
.Build();
3735

38-
using (application)
36+
using (host)
3937
{
40-
application.Start();
38+
host.Start();
4139
Console.ReadLine();
4240
}
4341
}

samples/SampleStartups/StartupConfigureAddresses.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ public void Configure(IApplicationBuilder app)
2727
// Entry point for the application.
2828
public static void Main(string[] args)
2929
{
30-
var config = WebApplicationConfiguration.GetDefault(args);
31-
32-
var application = new WebApplicationBuilder()
33-
.UseConfiguration(config)
30+
var host = new WebHostBuilder()
31+
.UseDefaultConfiguration(args)
3432
.UseStartup<StartupConfigureAddresses>()
3533
.UseUrls("http://localhost:5000", "http://localhost:5001")
3634
.Build();
3735

38-
application.Run();
36+
host.Run();
3937
}
4038
}
4139
}

samples/SampleStartups/StartupExternallyControlled.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace SampleStartups
1111
{
1212
public class StartupExternallyControlled
1313
{
14-
private IWebApplication _application;
14+
private IWebHost _host;
1515
private readonly List<string> _urls = new List<string>();
1616

1717
// This method gets called by the runtime. Use this method to add services to the container.
@@ -35,14 +35,14 @@ public StartupExternallyControlled()
3535

3636
public void Start()
3737
{
38-
_application = new WebApplicationBuilder()
38+
_host = new WebHostBuilder()
3939
.UseStartup<StartupExternallyControlled>()
4040
.Start(_urls.ToArray());
4141
}
4242

4343
public void Stop()
4444
{
45-
_application.Dispose();
45+
_host.Dispose();
4646
}
4747

4848
public void AddUrl(string url)

samples/SampleStartups/StartupFullControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class StartupFullControl
1313
{
1414
public static void Main(string[] args)
1515
{
16-
var application = new WebApplicationBuilder()
16+
var host = new WebHostBuilder()
1717
.UseServer("Microsoft.AspNet.Server.Kestrel") // Set the server manually
1818
.UseApplicationBasePath(Directory.GetCurrentDirectory()) // Override the application base with the current directory
1919
.UseUrls("http://*:1000", "https://*:902")
@@ -35,7 +35,7 @@ public static void Main(string[] args)
3535
})
3636
.Build();
3737

38-
application.Run();
38+
host.Run();
3939
}
4040
}
4141

samples/SampleStartups/StartupHelloWorld.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ public void Configure(IApplicationBuilder app)
2727
// Entry point for the application.
2828
public static void Main(string[] args)
2929
{
30-
var config = WebApplicationConfiguration.GetDefault(args);
31-
32-
var application = new WebApplicationBuilder()
33-
.UseConfiguration(config)
30+
var host = new WebHostBuilder()
31+
.UseDefaultConfiguration(args)
3432
.UseStartup<StartupHelloWorld>()
3533
.Build();
3634

37-
application.Run();
35+
host.Run();
3836
}
3937
}
4038
}

src/Microsoft.AspNet.Hosting.Abstractions/IHostingEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public interface IHostingEnvironment
1616
/// of the "Hosting:Environment" (on Windows) or "Hosting__Environment" (on Linux &amp; OS X) environment variable.
1717
/// </summary>
1818
// This must be settable!
19-
string EnvironmentName { get; set; }
19+
string EnvironmentName { get; set; }
2020

2121
/// <summary>
2222
/// Gets or sets the absolute path to the directory that contains the web-servable application content files.

src/Microsoft.AspNet.Hosting.Abstractions/IWebApplicationBuilder.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Microsoft.AspNet.Hosting.Abstractions/IWebApplication.cs renamed to src/Microsoft.AspNet.Hosting.Abstractions/IWebHost.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
namespace Microsoft.AspNet.Hosting
88
{
99
/// <summary>
10-
/// Represents a configured web application
10+
/// Represents a configured web host
1111
/// </summary>
12-
public interface IWebApplication : IDisposable
12+
public interface IWebHost : IDisposable
1313
{
1414
/// <summary>
1515
/// The <see cref="IFeatureCollection"/> exposed by the configured server.
1616
/// </summary>
1717
IFeatureCollection ServerFeatures { get; }
1818

1919
/// <summary>
20-
/// The <see cref="IServiceProvider"/> for the application.
20+
/// The <see cref="IServiceProvider"/> for the host.
2121
/// </summary>
2222
IServiceProvider Services { get; }
2323

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using Microsoft.AspNet.Builder;
7+
using Microsoft.AspNet.Hosting.Server;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.DependencyInjection;
10+
11+
namespace Microsoft.AspNet.Hosting
12+
{
13+
/// <summary>
14+
/// A builder for <see cref="IWebHost"/>
15+
/// </summary>
16+
public interface IWebHostBuilder
17+
{
18+
/// <summary>
19+
/// Builds an <see cref="IWebHost"/> which hosts a web application.
20+
/// </summary>
21+
IWebHost Build();
22+
23+
/// <summary>
24+
/// Gets the raw settings to be used by the web host. Values specified here will override
25+
/// the configuration set by <see cref="UseConfiguration(IConfiguration)"/>.
26+
/// </summary>
27+
IDictionary<string, string> Settings { get; }
28+
29+
/// <summary>
30+
/// Specify the <see cref="IConfiguration"/> to be used by the web host. If no configuration is
31+
/// provided to the builder, the default configuration will be used.
32+
/// </summary>
33+
/// <param name="configuration">The <see cref="IConfiguration"/> to be used.</param>
34+
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
35+
IWebHostBuilder UseConfiguration(IConfiguration configuration);
36+
37+
/// <summary>
38+
/// Specify the <see cref="IServerFactory"/> to be used by the web host.
39+
/// </summary>
40+
/// <param name="factory">The <see cref="IServerFactory"/> to be used.</param>
41+
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
42+
IWebHostBuilder UseServer(IServerFactory factory);
43+
44+
/// <summary>
45+
/// Specify the startup type to be used by the web host.
46+
/// </summary>
47+
/// <param name="startupType">The <see cref="Type"/> to be used.</param>
48+
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
49+
IWebHostBuilder UseStartup(Type startupType);
50+
51+
/// <summary>
52+
/// Specify the delegate that is used to configure the services of the web application.
53+
/// </summary>
54+
/// <param name="configureServices">The delegate that configures the <see cref="IServiceCollection"/>.</param>
55+
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
56+
IWebHostBuilder ConfigureServices(Action<IServiceCollection> configureServices);
57+
58+
/// <summary>
59+
/// Specify the startup method to be used to configure the web application.
60+
/// </summary>
61+
/// <param name="configureApplication">The delegate that configures the <see cref="IApplicationBuilder"/>.</param>
62+
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
63+
IWebHostBuilder Configure(Action<IApplicationBuilder> configureApplication);
64+
65+
/// <summary>
66+
/// Add or replace a setting in <see cref="Settings"/>.
67+
/// </summary>
68+
/// <param name="key">The key of the setting to add or replace.</param>
69+
/// <param name="value">The value of the setting to add or replace.</param>
70+
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
71+
IWebHostBuilder UseSetting(string key, string value);
72+
}
73+
}

src/Microsoft.AspNet.Hosting.Abstractions/WebApplicationDefaults.cs renamed to src/Microsoft.AspNet.Hosting.Abstractions/WebHostDefaults.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Microsoft.AspNet.Hosting
55
{
6-
public static class WebApplicationDefaults
6+
public static class WebHostDefaults
77
{
88
public static readonly string ApplicationKey = "application";
99
public static readonly string DetailedErrorsKey = "detailedErrors";

src/Microsoft.AspNet.Hosting.WindowsServices/WebApplicationService.cs renamed to src/Microsoft.AspNet.Hosting.WindowsServices/WebHostService.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System;
54
using System.ServiceProcess;
65
using Microsoft.Extensions.DependencyInjection;
76

@@ -10,25 +9,25 @@ namespace Microsoft.AspNet.Hosting.WindowsServices
109
/// <summary>
1110
/// Provides an implementation of a Windows service that hosts ASP.NET.
1211
/// </summary>
13-
public class WebApplicationService : ServiceBase
12+
public class WebHostService : ServiceBase
1413
{
15-
private IWebApplication _application;
14+
private IWebHost _host;
1615
private bool _stopRequestedByWindows;
1716

1817
/// <summary>
19-
/// Creates an instance of <c>WebApplicationService</c> which hosts the specified web application.
18+
/// Creates an instance of <c>WebHostService</c> which hosts the specified web application.
2019
/// </summary>
21-
/// <param name="application">The web application to host in the Windows service.</param>
22-
public WebApplicationService(IWebApplication application)
20+
/// <param name="host">The configured web host containing the web application to host in the Windows service.</param>
21+
public WebHostService(IWebHost host)
2322
{
24-
_application = application;
23+
_host = host;
2524
}
2625

2726
protected sealed override void OnStart(string[] args)
2827
{
2928
OnStarting(args);
3029

31-
_application
30+
_host
3231
.Services
3332
.GetRequiredService<IApplicationLifetime>()
3433
.ApplicationStopped
@@ -40,7 +39,7 @@ protected sealed override void OnStart(string[] args)
4039
}
4140
});
4241

43-
_application.Start();
42+
_host.Start();
4443

4544
OnStarted();
4645
}
@@ -49,7 +48,7 @@ protected sealed override void OnStop()
4948
{
5049
_stopRequestedByWindows = true;
5150
OnStopping();
52-
_application?.Dispose();
51+
_host?.Dispose();
5352
OnStopped();
5453
}
5554

src/Microsoft.AspNet.Hosting.WindowsServices/WebApplicationExtensions.cs renamed to src/Microsoft.AspNet.Hosting.WindowsServices/WebHostWindowsServiceExtensions.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@
66
namespace Microsoft.AspNet.Hosting.WindowsServices
77
{
88
/// <summary>
9-
/// Extensions to <see cref="IWebApplication" for hosting inside a Windows service. />
9+
/// Extensions to <see cref="IWebHost" for hosting inside a Windows service. />
1010
/// </summary>
11-
public static class WebApplicationExtensions
11+
public static class WebHostWindowsServiceExtensions
1212
{
1313
/// <summary>
1414
/// Runs the specified web application inside a Windows service and blocks until the service is stopped.
1515
/// </summary>
16-
/// <param name="application">An instance of the <see cref="IWebApplication"/> to host in the Windows service.</param>
16+
/// <param name="host">An instance of the <see cref="IWebHost"/> to host in the Windows service.</param>
1717
/// <example>
18-
/// This example shows how to use <see cref="WebApplicationService.Run"/>.
18+
/// This example shows how to use <see cref="WebHostService.Run"/>.
1919
/// <code>
2020
/// public class Program
2121
/// {
2222
/// public static void Main(string[] args)
2323
/// {
24-
/// var config = WebApplicationConfiguration.GetDefault(args);
24+
/// var config = WebHostConfiguration.GetDefault(args);
2525
///
26-
/// var application = new WebApplicationBuilder()
26+
/// var host = new WebHostBuilder()
2727
/// .UseConfiguration(config)
2828
/// .Build();
2929
///
3030
/// // This call will block until the service is stopped.
31-
/// application.RunAsService();
31+
/// host.RunAsService();
3232
/// }
3333
/// }
3434
/// </code>
3535
/// </example>
36-
public static void RunAsService(this IWebApplication application)
36+
public static void RunAsService(this IWebHost host)
3737
{
38-
var webApplicationService = new WebApplicationService(application);
39-
ServiceBase.Run(webApplicationService);
38+
var webHostService = new WebHostService(host);
39+
ServiceBase.Run(webHostService);
4040
}
4141
}
4242
}

src/Microsoft.AspNet.Hosting/Internal/HostingEnvironmentExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Hosting.Internal
1111
{
1212
public static class HostingEnvironmentExtensions
1313
{
14-
public static void Initialize(this IHostingEnvironment hostingEnvironment, string applicationBasePath, WebApplicationOptions options, IConfiguration configuration)
14+
public static void Initialize(this IHostingEnvironment hostingEnvironment, string applicationBasePath, WebHostOptions options, IConfiguration configuration)
1515
{
1616
if (options == null)
1717
{

0 commit comments

Comments
 (0)