DiagnosticListener 類別

定義

提供抽象的 DiagnosticSource 類別實作,表示來源傳送其資訊 (事件) 的具名位置。Provides an implementation of the abstract DiagnosticSource class that represents a named place to which a source sends its information (events).

public ref class DiagnosticListener : System::Diagnostics::DiagnosticSource, IDisposable, IObservable<System::Collections::Generic::KeyValuePair<System::String ^, System::Object ^>>
public class DiagnosticListener : System.Diagnostics.DiagnosticSource, IDisposable, IObservable<System.Collections.Generic.KeyValuePair<string,object>>
type DiagnosticListener = class
    inherit DiagnosticSource
    interface IDisposable
    interface IObservable<KeyValuePair<string, obj>>
Public Class DiagnosticListener
Inherits DiagnosticSource
Implements IDisposable, IObservable(Of KeyValuePair(Of String, Object))
繼承
DiagnosticListener
實作

備註

DiagnosticListener 是 NotificationSource,這表示傳回的結果可以用來記錄通知,但它也具有 @no__t 1 方法,因此可以任意轉送通知。DiagnosticListener is a NotificationSource, which means the returned result can be used to log notifications, but it also has a Subscribe method so notifications can be forwarded arbitrarily. 因此,其工作是將來自生產者的事物轉送到所有接聽程式(多轉換)。Thus, its job is to forward things from the producer to all the listeners (multi-casting). 一般來說,您不應該讓自己的 DiagnosticListener,而是使用預設值,如此一來,通知就會盡可能公開。Generally, you should not be making your own DiagnosticListener but use the default, so that notifications are as public as possible.

如需有關 DiagnosticSource 和 @no__t 1 類別的詳細資訊,請參閱DiagnosticSource 使用者手冊For more information on the DiagnosticSource and DiagnosticListener classes, see DiagnosticSource User's Guide.

建構函式

DiagnosticListener(String)

建立新的 DiagnosticListenerCreates a new DiagnosticListener.

屬性

AllListeners

取得此 DiagnosticListener 的接聽程式集合。Gets the collection of listeners for this DiagnosticListener.

Name

取得這個 DiagnosticListener 的名稱。Gets the name of this DiagnosticListener.

方法

Dispose()

處置 NotificationListeners。Disposes the NotificationListeners.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IsEnabled()

判斷是否有任何已註冊的訂閱者。Determines whether there are any registered subscribers.

IsEnabled(String)

檢查是否啟用 DiagnosticListenerChecks whether the DiagnosticListener is enabled.

IsEnabled(String, Object, Object)

檢查是否啟用 DiagnosticListener。Checks if the DiagnosticListener is enabled.

MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnActivityExport(Activity, Object)

叫用所有訂閱者的 OnActivityExport 方法。Invokes the OnActivityExport method of all the subscribers.

OnActivityImport(Activity, Object)

叫用所有訂閱者的 OnActivityImport 方法。Invokes the OnActivityImport method of all the subscribers.

StartActivity(Activity, Object)

啟動 Activity 並寫入啟動事件。Starts an Activity and writes a start event.

(繼承來源 DiagnosticSource)
StopActivity(Activity, Object)

停止指定的 Activity,維護全域 Current 活動,然後通知取用者已停止 ActivityStops the given Activity, maintains the global Current activity, and notifies consumers that the Activity was stopped.

(繼承來源 DiagnosticSource)
Subscribe(IObserver<KeyValuePair<String,Object>>)

新增訂閱者。Adds a subscriber.

Subscribe(IObserver<KeyValuePair<String,Object>>, Func<String,Object,Object,Boolean>)

新增訂閱者,並選擇性地根據其名稱和最多兩個內容事件物件來篩選事件。Adds a subscriber, and optionally filters events based on their name and up to two context objects.

Subscribe(IObserver<KeyValuePair<String,Object>>, Func<String,Object,Object,Boolean>, Action<Activity,Object>, Action<Activity,Object>)

新增訂閱者,選擇地根據其名稱和最多兩個內容物件來篩選事件,並指定提供者從處理序外部匯入或匯出活動時要呼叫的方法。Adds a subscriber, optionally filters events based on their name and up to two context objects, and specifies methods to call when providers import or export activites from outside the process.

Subscribe(IObserver<KeyValuePair<String,Object>>, Predicate<String>)

新增訂閱者,並選擇性地根據其名稱來篩選事件。Adds a subscriber, and optionally filters events based on their name.

ToString()

傳回名稱為此 DiagnosticListener 的字串。Returns a string with the name of this DiagnosticListener.

Write(String, Object)

記錄通知。Logs a notification.

適用於