EventAttribute.Message Właściwość

Definicja

Pobiera lub ustawia komunikat dla zdarzenia.

public:
 property System::String ^ Message { System::String ^ get(); void set(System::String ^ value); };
public string Message { get; set; }
public string? Message { get; set; }
member this.Message : string with get, set
Public Property Message As String

Wartość właściwości

Komunikat zdarzenia.

Przykłady

W poniższym przykładzie pokazano, jak używać właściwości do określania Message komunikatów o zdarzeniach. Ten przykład kodu jest częścią większego przykładu podanego EventSource dla klasy.

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }
<[Event](1, Message:="Application Failure: {0}", Level:=EventLevel.Error, Keywords:=Keywords.Diagnostic)> _
Public Sub Failure(ByVal message As String)
    WriteEvent(1, message)
End Sub
[Event(2, Message = "Starting up.", Keywords = Keywords.Perf, Level = EventLevel.Informational)]
public void Startup() { WriteEvent(2); }
<[Event](2, Message:="Starting up.", Keywords:=Keywords.Perf, Level:=EventLevel.Informational)> _
Public Sub Startup()
    WriteEvent(2)
End Sub
[Event(3, Message = "loading page {1} activityID={0}", Opcode = EventOpcode.Start,
    Task = Tasks.Page, Keywords = Keywords.Page, Level = EventLevel.Informational)]
public void PageStart(int ID, string url) { if (IsEnabled()) WriteEvent(3, ID, url); }
<[Event](3, Message:="loading page {1} activityID={0}", Opcode:=EventOpcode.Start, Task:=Tasks.Page, Keywords:=Keywords.Page, Level:=EventLevel.Informational)> _
Public Sub PageStart(ByVal ID As Integer, ByVal url As String)
    If IsEnabled() Then
        WriteEvent(3, ID, url)
    End If
End Sub

Uwagi

W ciągu można użyć standardowych operatorów podstawień .NET Framework (na przykład {1}). Zostaną one zastąpione reprezentacją ciągu odpowiadającej mu części ładunku zdarzenia.

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]  
        public void Failure(string message) { WriteEvent(1, message); }  

Dotyczy