DiagnosticSource.Write 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| Write(String, Object) |
提供一種通用方式來記錄複雜有效載荷。 |
| Write<T>(String, T) |
提供一種通用方式來記錄複雜有效載荷。 |
Write(String, Object)
提供一種通用方式來記錄複雜有效載荷。
public:
abstract void Write(System::String ^ name, System::Object ^ value);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of object being written to DiagnosticSource cannot be discovered statically.")]
public abstract void Write(string name, object? value);
public abstract void Write(string name, object? value);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of object being written to DiagnosticSource cannot be discovered statically.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("DiagnosticSource may require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
public abstract void Write(string name, object? value);
public abstract void Write(string name, object value);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of object being written to DiagnosticSource cannot be discovered statically.")>]
abstract member Write : string * obj -> unit
abstract member Write : string * obj -> unit
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of object being written to DiagnosticSource cannot be discovered statically.")>]
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("DiagnosticSource may require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
abstract member Write : string * obj -> unit
Public MustOverride Sub Write (name As String, value As Object)
參數
- name
- String
事件名稱正在書寫。
- value
- Object
一個代表事件有效載荷所傳遞值的物件。 這通常是匿名型態,包含多個子值。
- 屬性
備註
每個通知都會被賦予一個名稱來識別它,以及一個物件(通常是匿名型態),提供任意資訊以傳遞給通知。
name 應該很短。 除非必須避免歧義,否則不要使用完全限定的名稱,因為 name 必須是全域唯一的。 通常, componentName.eventName( componentName 和 eventName 字串少於 10 個字元)是個不錯的折衷方案。
通知名稱不應該包含在其中, . 因為元件名稱有點,且兩者都有點會造成歧義。 我們建議你改用 _ 。
假設聽者會使用字串前綴來過濾群組。 因此,擁有元件名稱的階層結構是一種良好的做法。
適用於
Write<T>(String, T)
提供一種通用方式來記錄複雜有效載荷。
public:
generic <typename T>
void Write(System::String ^ name, T value);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Only the properties of the T type will be preserved. Properties of referenced types and properties of derived types may be trimmed.")]
public void Write<T>(string name, T value);
public void Write<T>(string name, T value);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Only the properties of the T type will be preserved. Properties of referenced types and properties of derived types may be trimmed.")>]
member this.Write : string * 'T -> unit
member this.Write : string * 'T -> unit
Public Sub Write(Of T) (name As String, value As T)
類型參數
- T
事件中傳遞的值類型。
參數
- name
- String
事件名稱正在書寫。
- value
- T
一個代表事件有效載荷所傳遞值的物件。 這通常是匿名型態,包含多個子值。
- 屬性