SourceFilter(String) Конструктор

Определение

Инициализирует новый экземпляр класса SourceFilter, задающего имя источника трассировки.

public:
 SourceFilter(System::String ^ source);
public SourceFilter (string source);
new System.Diagnostics.SourceFilter : string -> System.Diagnostics.SourceFilter
Public Sub New (source As String)

Параметры

source
String

Имя источника трассировки.

Примеры

В следующем примере кода метод вызывается TraceData с помощью двух разных фильтров источника: один с вымышленным именем, другой — с именем текущего источника трассировки. В первом случае трассировка не записывается в консоль; во втором случае записывается трассировка. Этот пример входит в состав более крупного примера использования класса TraceSource.

// Test the filter on the ConsoleTraceListener.
ts.Listeners["console"].Filter = new SourceFilter("No match");
ts.TraceData(TraceEventType.Information, 5,
    "SourceFilter should reject this message for the console trace listener.");
ts.Listeners["console"].Filter = new SourceFilter("TraceTest");
ts.TraceData(TraceEventType.Information, 6,
    "SourceFilter should let this message through on the console trace listener.");
' Test the filter on the ConsoleTraceListener.
ts.Listeners("console").Filter = New SourceFilter("No match")
ts.TraceData(TraceEventType.Information, 5, "SourceFilter should reject this message for the console trace listener.")
ts.Listeners("console").Filter = New SourceFilter("TraceTest")
ts.TraceData(TraceEventType.Information, 6, "SourceFilter should let this message through on the console trace listener.")

Комментарии

Значение source параметра используется для инициализации Source свойства .

Применяется к