Add IsDevelopment and IsProduction extension methods

This commit is contained in:
Glenn Condron 2015-03-25 21:22:50 -07:00 committed by David Fowler
parent e19289f7ac
commit c390d47317
1 changed files with 23 additions and 0 deletions

View File

@ -9,6 +9,29 @@ namespace Microsoft.AspNet.Hosting
{
public static class HostingEnvironmentExtensions
{
private const string DevelopmentEnvironmentName = "Development";
private const string ProductionEnvironmentName = "Production";
/// <summary>
/// Checks if the current hosting environment name is development.
/// </summary>
/// <param name="hostingEnvironment">An instance of <see cref="IHostingEnvironment"/> service.</param>
/// <returns>True if the environment name is Development, otherwise false.</returns>
public static bool IsDevelopment([NotNull]this IHostingEnvironment hostingEnvironment)
{
return hostingEnvironment.IsEnvironment(DevelopmentEnvironmentName);
}
/// <summary>
/// Checks if the current hosting environment name is Production.
/// </summary>
/// <param name="hostingEnvironment">An instance of <see cref="IHostingEnvironment"/> service.</param>
/// <returns>True if the environment name is Production, otherwise false.</returns>
public static bool IsProduction([NotNull]this IHostingEnvironment hostingEnvironment)
{
return hostingEnvironment.IsEnvironment(ProductionEnvironmentName);
}
/// <summary>
/// Compares the current hosting environment name against the specified value.
/// </summary>