diff --git a/src/Microsoft.AspNet.Hosting.Abstractions/HostingEnvironmentExtensions.cs b/src/Microsoft.AspNet.Hosting.Abstractions/HostingEnvironmentExtensions.cs index c0838231fc..d0baeb570f 100644 --- a/src/Microsoft.AspNet.Hosting.Abstractions/HostingEnvironmentExtensions.cs +++ b/src/Microsoft.AspNet.Hosting.Abstractions/HostingEnvironmentExtensions.cs @@ -9,6 +9,29 @@ namespace Microsoft.AspNet.Hosting { public static class HostingEnvironmentExtensions { + private const string DevelopmentEnvironmentName = "Development"; + private const string ProductionEnvironmentName = "Production"; + + /// + /// Checks if the current hosting environment name is development. + /// + /// An instance of service. + /// True if the environment name is Development, otherwise false. + public static bool IsDevelopment([NotNull]this IHostingEnvironment hostingEnvironment) + { + return hostingEnvironment.IsEnvironment(DevelopmentEnvironmentName); + } + + /// + /// Checks if the current hosting environment name is Production. + /// + /// An instance of service. + /// True if the environment name is Production, otherwise false. + public static bool IsProduction([NotNull]this IHostingEnvironment hostingEnvironment) + { + return hostingEnvironment.IsEnvironment(ProductionEnvironmentName); + } + /// /// Compares the current hosting environment name against the specified value. ///