Читати англійською Редагувати

Поділитися через


DiagnosticSource.IsEnabled Method

Definition

Overloads

IsEnabled(String)

Verifies if the notification event is enabled.

IsEnabled(String, Object, Object)

Verifies it the notification event is enabled.

IsEnabled(String)

Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs

Verifies if the notification event is enabled.

C#
public abstract bool IsEnabled(string name);

Parameters

name
String

The name of the event being written.

Returns

true if the notification event is enabled, false otherwise.

Remarks

If there is expensive setup for the notification, you can call IsEnabled before performing this setup. Consumers should not assume that they only get notifications for which IsEnabled is true. However, it is optional for producers to call this API. The name should be the same as that passed to Write(String, Object).

Applies to

.NET 10 та інші версії
Продукт Версії
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

IsEnabled(String, Object, Object)

Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs

Verifies it the notification event is enabled.

C#
public virtual bool IsEnabled(string name, object? arg1, object? arg2 = default);
C#
public virtual bool IsEnabled(string name, object arg1, object arg2 = default);

Parameters

name
String

The name of the event being written.

arg1
Object

An object that represents the additional context for IsEnabled. Consumers should expect to receive null which may indicate that producer called pure IsEnabled(string) to check if consumer wants to get notifications for such events at all. Based on that, producer may call IsEnabled(string, object, object) again with non-null context.

arg2
Object

Optional. An object that represents the additional context for IsEnabled. null by default. Consumers should expect to receive null which may indicate that producer called pure IsEnabled(string) or producer passed all necessary context in arg1.

Returns

true if the notification event is enabled, false otherwise.

Remarks

If there is expensive setup for the notification, you can call this method and provide context before performing the setup.

Applies to

.NET 10 та інші версії
Продукт Версії
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)