HostEnvironmentEnvExtensions.IsEnvironment(IHostEnvironment, String) 方法

定义

将当前主机环境名称与指定的值进行比较。Compares the current host environment name against the specified value. 库作者应避免使用此 API。有关详细信息,请参阅注解。Library authors should avoid using this API, see remarks for details.

public:
[System::Runtime::CompilerServices::Extension]
 static bool IsEnvironment(Microsoft::Extensions::Hosting::IHostEnvironment ^ hostEnvironment, System::String ^ environmentName);
public static bool IsEnvironment (this Microsoft.Extensions.Hosting.IHostEnvironment hostEnvironment, string environmentName);
static member IsEnvironment : Microsoft.Extensions.Hosting.IHostEnvironment * string -> bool
<Extension()>
Public Function IsEnvironment (hostEnvironment As IHostEnvironment, environmentName As String) As Boolean

参数

hostEnvironment
IHostEnvironment

IHostEnvironment 的一个实例。An instance of IHostEnvironment.

environmentName
String

要对其进行验证的环境名称。Environment name to validate against.

返回

Boolean

如果指定的名称与当前环境相同,则为 true;否则为 falsetrue if the specified name is the same as the current environment; otherwise, false.

注解

环境名称通常是特定于应用程序的。Environment names are generally specific to an application. 设计为在许多不同的应用程序中使用的库应避免将行为耦合到特定的环境名称。Libraries designed for use in many different applications should avoid coupling behavior to specific environment names.

适用于