From cfab182399e2a22f3e6d87a8875396fced6078c8 Mon Sep 17 00:00:00 2001 From: Henk Mollema Date: Mon, 18 Jun 2018 19:47:17 +0200 Subject: [PATCH] Revert "Inherit web IHostingEnvironment and IApplicationEnvironment from the Generic Host one (#1461)" (#1467) This reverts commit 8672b1b04a9abc44377a5eac2b89d2fdeb7f0004. --- .../IApplicationLifetime.cs | 25 ++++++++++++++++++- .../IHostingEnvironment.cs | 24 +++++++++++++++++- .../Internal/ApplicationLifetime.cs | 2 +- .../Internal/HostingEnvironment.cs | 2 +- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/IApplicationLifetime.cs b/src/Microsoft.AspNetCore.Hosting.Abstractions/IApplicationLifetime.cs index cba94f40fe..f4613dd7d9 100644 --- a/src/Microsoft.AspNetCore.Hosting.Abstractions/IApplicationLifetime.cs +++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/IApplicationLifetime.cs @@ -8,7 +8,30 @@ namespace Microsoft.AspNetCore.Hosting /// /// Allows consumers to perform cleanup during a graceful shutdown. /// - public interface IApplicationLifetime : Extensions.Hosting.IApplicationLifetime + public interface IApplicationLifetime { + /// + /// Triggered when the application host has fully started and is about to wait + /// for a graceful shutdown. + /// + CancellationToken ApplicationStarted { get; } + + /// + /// Triggered when the application host is performing a graceful shutdown. + /// Requests may still be in flight. Shutdown will block until this event completes. + /// + CancellationToken ApplicationStopping { get; } + + /// + /// Triggered when the application host is performing a graceful shutdown. + /// All requests should be complete at this point. Shutdown will block + /// until this event completes. + /// + CancellationToken ApplicationStopped { get; } + + /// + /// Requests termination of the current application. + /// + void StopApplication(); } } diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/IHostingEnvironment.cs b/src/Microsoft.AspNetCore.Hosting.Abstractions/IHostingEnvironment.cs index 8278ba9f85..5feeb38eb7 100644 --- a/src/Microsoft.AspNetCore.Hosting.Abstractions/IHostingEnvironment.cs +++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/IHostingEnvironment.cs @@ -8,8 +8,20 @@ namespace Microsoft.AspNetCore.Hosting /// /// Provides information about the web hosting environment an application is running in. /// - public interface IHostingEnvironment : Extensions.Hosting.IHostingEnvironment + public interface IHostingEnvironment { + /// + /// Gets or sets the name of the environment. The host automatically sets this property to the value + /// of the "ASPNETCORE_ENVIRONMENT" environment variable, or "environment" as specified in any other configuration source. + /// + string EnvironmentName { get; set; } + + /// + /// Gets or sets the name of the application. This property is automatically set by the host to the assembly containing + /// the application entry point. + /// + string ApplicationName { get; set; } + /// /// Gets or sets the absolute path to the directory that contains the web-servable application content files. /// @@ -19,5 +31,15 @@ namespace Microsoft.AspNetCore.Hosting /// Gets or sets an pointing at . /// IFileProvider WebRootFileProvider { get; set; } + + /// + /// Gets or sets the absolute path to the directory that contains the application content files. + /// + string ContentRootPath { get; set; } + + /// + /// Gets or sets an pointing at . + /// + IFileProvider ContentRootFileProvider { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/ApplicationLifetime.cs b/src/Microsoft.AspNetCore.Hosting/Internal/ApplicationLifetime.cs index 47d16e9654..958f8b5dcc 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/ApplicationLifetime.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/ApplicationLifetime.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal /// /// Allows consumers to perform cleanup during a graceful shutdown. /// - public class ApplicationLifetime : IApplicationLifetime + public class ApplicationLifetime : IApplicationLifetime, Extensions.Hosting.IApplicationLifetime { private readonly CancellationTokenSource _startedSource = new CancellationTokenSource(); private readonly CancellationTokenSource _stoppingSource = new CancellationTokenSource(); diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/HostingEnvironment.cs b/src/Microsoft.AspNetCore.Hosting/Internal/HostingEnvironment.cs index 34924ab365..1f8d1887d7 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/HostingEnvironment.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/HostingEnvironment.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.FileProviders; namespace Microsoft.AspNetCore.Hosting.Internal { - public class HostingEnvironment : IHostingEnvironment + public class HostingEnvironment : IHostingEnvironment, Extensions.Hosting.IHostingEnvironment { public string EnvironmentName { get; set; } = Hosting.EnvironmentName.Production;