EventAttribute クラス

定義

イベントに追加イベントのスキーマ情報を指定します。

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
継承
EventAttribute
属性

次の例は、 クラスを使用 EventAttribute してさまざまなイベントを定義する方法を示しています。 このコード例は、EventSource クラスのために提供されている大規模な例の一部です。

[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

注釈

派生クラスで定義されている ETW イベント メソッドにこの属性を EventSource適用する場合は、基底クラスで メソッドを WriteEvent 呼び出し、イベント ID を渡し、その後に定義されたメソッドが渡されるのと同じ引数を渡す必要があります。 次の例に示すパターンに従う必要があります。

コンストラクター

EventAttribute(Int32)

指定したイベント識別子を使用して、EventAttribute クラスの新しいインスタンスを初期化します。

プロパティ

ActivityOptions

アクティビティの開始および停止イベントの動作を指定します。 アクティビティは、アプリの開始から停止までの時間の範囲です。

Channel

イベントの書き込み先となる追加のイベント ログを取得または設定します。

EventId

イベントの識別子を取得または設定します。

Keywords

イベントのキーワードを取得または設定します。

Level

イベントのレベルを取得または設定します。

Message

イベントのメッセージを取得または設定します。

Opcode

イベントのオペレーション コードを取得または設定します。

Tags

この EventAttribute オブジェクトの EventTags 値を取得または設定します。 イベント タグは、イベントがログされたときに渡されるユーザー定義の値です。

Task

イベントのタスクを取得または設定します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)
Version

イベントのバージョンを取得または設定します。

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

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

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象