HealthChecksBuilderAddCheckExtensions.AddCheck 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
AddCheck(IHealthChecksBuilder, String, IHealthCheck, Nullable<HealthStatus>, IEnumerable<String>)
新增具有指定名稱和實作的新健康狀態檢查。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHealthChecksBuilder ^ AddCheck(Microsoft::Extensions::DependencyInjection::IHealthChecksBuilder ^ builder, System::String ^ name, Microsoft::Extensions::Diagnostics::HealthChecks::IHealthCheck ^ instance, Nullable<Microsoft::Extensions::Diagnostics::HealthChecks::HealthStatus> failureStatus, System::Collections::Generic::IEnumerable<System::String ^> ^ tags);
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck (this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags);
static member AddCheck : Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder * string * Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck * Nullable<Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus> * seq<string> -> Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder
<Extension()>
Public Function AddCheck (builder As IHealthChecksBuilder, name As String, instance As IHealthCheck, failureStatus As Nullable(Of HealthStatus), tags As IEnumerable(Of String)) As IHealthChecksBuilder
參數
- builder
- IHealthChecksBuilder
- name
- String
健康狀態檢查的名稱。
- instance
- IHealthCheck
IHealthCheck 執行個體。
- failureStatus
- Nullable<HealthStatus>
當健康狀態檢查回報失敗時應回報的 HealthStatus。 如果提供的值為 null
,則會回報 Unhealthy。
- tags
- IEnumerable<String>
可用來篩選健康狀態檢查的標籤清單。
傳回
適用於
AddCheck(IHealthChecksBuilder, String, IHealthCheck, Nullable<HealthStatus>, IEnumerable<String>, Nullable<TimeSpan>)
新增具有指定名稱和實作的新健康狀態檢查。
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck (this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default, System.Collections.Generic.IEnumerable<string>? tags = default, TimeSpan? timeout = default);
static member AddCheck : Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder * string * Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck * Nullable<Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus> * seq<string> * Nullable<TimeSpan> -> Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder
<Extension()>
Public Function AddCheck (builder As IHealthChecksBuilder, name As String, instance As IHealthCheck, Optional failureStatus As Nullable(Of HealthStatus) = Nothing, Optional tags As IEnumerable(Of String) = Nothing, Optional timeout As Nullable(Of TimeSpan) = Nothing) As IHealthChecksBuilder
參數
- builder
- IHealthChecksBuilder
- name
- String
健康狀態檢查的名稱。
- instance
- IHealthCheck
IHealthCheck 執行個體。
- failureStatus
- Nullable<HealthStatus>
當健康狀態檢查回報失敗時應回報的 HealthStatus。 如果提供的值為 null
,則會回報 Unhealthy。
- tags
- IEnumerable<String>
可用來篩選健康狀態檢查的標籤清單。
傳回
適用於
AddCheck<T>(IHealthChecksBuilder, String, Nullable<HealthStatus>, IEnumerable<String>)
新增具有指定名稱和實作的新健康狀態檢查。
public:
generic <typename T>
where T : class, Microsoft::Extensions::Diagnostics::HealthChecks::IHealthCheck[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHealthChecksBuilder ^ AddCheck(Microsoft::Extensions::DependencyInjection::IHealthChecksBuilder ^ builder, System::String ^ name, Nullable<Microsoft::Extensions::Diagnostics::HealthChecks::HealthStatus> failureStatus, System::Collections::Generic::IEnumerable<System::String ^> ^ tags);
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck<T> (this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck;
static member AddCheck : Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder * string * Nullable<Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus> * seq<string> -> Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder (requires 'T : null and 'T :> Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck)
<Extension()>
Public Function AddCheck(Of T As {Class, IHealthCheck}) (builder As IHealthChecksBuilder, name As String, failureStatus As Nullable(Of HealthStatus), tags As IEnumerable(Of String)) As IHealthChecksBuilder
類型參數
- T
健康情況檢查實作類型。
參數
- builder
- IHealthChecksBuilder
- name
- String
健康狀態檢查的名稱。
- failureStatus
- Nullable<HealthStatus>
當健康狀態檢查回報失敗時應回報的 HealthStatus。 如果提供的值為 null
,則會回報 Unhealthy。
- tags
- IEnumerable<String>
可用來篩選健康狀態檢查的標籤清單。
傳回
備註
此方法會在需要時使用 GetServiceOrCreateInstance<T>(IServiceProvider) 來建立健康情況檢查實例。 如果類型的 T
服務已在相依性插入容器中註冊,則會使用任何存留期。 否則,將會使用從相依性插入容器存取服務的存取來建構 類型的 T
實例。
適用於
AddCheck<T>(IHealthChecksBuilder, String, Nullable<HealthStatus>, IEnumerable<String>, Nullable<TimeSpan>)
新增具有指定名稱和實作的新健康狀態檢查。
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck<T> (this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default, System.Collections.Generic.IEnumerable<string>? tags = default, TimeSpan? timeout = default) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck;
static member AddCheck : Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder * string * Nullable<Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus> * seq<string> * Nullable<TimeSpan> -> Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder (requires 'T : null and 'T :> Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck)
<Extension()>
Public Function AddCheck(Of T As {Class, IHealthCheck}) (builder As IHealthChecksBuilder, name As String, Optional failureStatus As Nullable(Of HealthStatus) = Nothing, Optional tags As IEnumerable(Of String) = Nothing, Optional timeout As Nullable(Of TimeSpan) = Nothing) As IHealthChecksBuilder
類型參數
- T
健康情況檢查實作類型。
參數
- builder
- IHealthChecksBuilder
- name
- String
健康狀態檢查的名稱。
- failureStatus
- Nullable<HealthStatus>
當健康狀態檢查回報失敗時應回報的 HealthStatus。 如果提供的值為 null
,則會回報 Unhealthy。
- tags
- IEnumerable<String>
可用來篩選健康狀態檢查的標籤清單。
傳回
備註
此方法會在需要時使用 GetServiceOrCreateInstance<T>(IServiceProvider) 來建立健康情況檢查實例。 如果類型的 T
服務已在相依性插入容器中註冊,則會使用任何存留期。 否則,將會使用從相依性插入容器存取服務的存取來建構 類型的 T
實例。