From c390d47317c8d0bdac35b1a22d4c180ea79791bb Mon Sep 17 00:00:00 2001 From: Glenn Condron Date: Wed, 25 Mar 2015 21:22:50 -0700 Subject: [PATCH] Add IsDevelopment and IsProduction extension methods --- .../HostingEnvironmentExtensions.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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. ///