EventAttribute Klasa

Definicja

Określa dodatkowe informacje o schemacie zdarzeń dla zdarzenia.

public ref class EventAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class EventAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type EventAttribute = class
    inherit Attribute
Public NotInheritable Class EventAttribute
Inherits Attribute
Dziedziczenie
EventAttribute
Atrybuty

Przykłady

W poniższym przykładzie pokazano, jak używać EventAttribute klasy do definiowania różnych zdarzeń. Ten przykład kodu jest częścią większego przykładu udostępnionego 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
[Event(4, Opcode = EventOpcode.Stop, Task = Tasks.Page, Keywords = Keywords.Page, Level = EventLevel.Informational)]
public void PageStop(int ID) { if (IsEnabled()) WriteEvent(4, ID); }
<[Event](4, Opcode:=EventOpcode.Stop, Task:=Tasks.Page, Keywords:=Keywords.Page, Level:=EventLevel.Informational)> _
Public Sub PageStop(ByVal ID As Integer)
    If IsEnabled() Then
        WriteEvent(4, ID)
    End If
End Sub

Uwagi

Po zastosowaniu tego atrybutu do metody zdarzenia ETW zdefiniowanej EventSourcew klasie pochodnej należy wywołać WriteEvent metodę w klasie bazowej, przekazując identyfikator zdarzenia, a następnie te same argumenty, co zdefiniowana metoda jest przekazywana. Należy postępować zgodnie ze wzorcem przedstawionym w poniższych przykładach.

Konstruktory

EventAttribute(Int32)

Inicjuje EventAttribute nowe wystąpienie klasy z określonym identyfikatorem zdarzenia.

Właściwości

ActivityOptions

Określa zachowanie zdarzeń uruchamiania i zatrzymywania działania. Działanie to region czasu w aplikacji między uruchomieniem a zatrzymaniem.

Channel

Pobiera lub ustawia dodatkowy dziennik zdarzeń, w którym ma zostać zapisane zdarzenie.

EventId

Pobiera lub ustawia identyfikator zdarzenia.

Keywords

Pobiera lub ustawia słowa kluczowe dla zdarzenia.

Level

Pobiera lub ustawia poziom zdarzenia.

Message

Pobiera lub ustawia komunikat dla zdarzenia.

Opcode

Pobiera lub ustawia kod operacji dla zdarzenia.

Tags

Pobiera lub ustawia EventTags wartość dla tego EventAttribute obiektu. Tag zdarzenia to wartość zdefiniowana przez użytkownika przekazywana po zarejestrowaniu zdarzenia.

Task

Pobiera lub ustawia zadanie dla zdarzenia.

TypeId

Po zaimplementowaniu w klasie pochodnej pobiera unikatowy identyfikator dla tego Attributeelementu .

(Odziedziczone po Attribute)
Version

Pobiera lub ustawia wersję zdarzenia.

Metody

Equals(Object)

Zwraca wartość wskazującą, czy to wystąpienie jest równe podanemu obiektowi.

(Odziedziczone po Attribute)
GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

(Odziedziczone po Attribute)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IsDefaultAttribute()

Podczas zastępowania w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną dla klasy pochodnej.

(Odziedziczone po Attribute)
Match(Object)

Po przesłonięciu w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie dla obiektu, który może służyć do pobierania informacji o typie dla interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy