EventInfo クラス
アセンブリ: mscorlib (mscorlib.dll 内)
構文
<SerializableAttribute> _ <ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.None)> _ Public MustInherit Class EventInfo Inherits MemberInfo Implements _EventInfo
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.None)] public abstract class EventInfo : MemberInfo, _EventInfo
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::None)] public ref class EventInfo abstract : public MemberInfo, _EventInfo
イベントはデリゲートを通じて使用されます。イベント リスナは、イベント ソースによってイベントが発生したときに必ず呼び出されるイベント ハンドラ デリゲートをインスタンス化します。イベント ソースに接続するために、イベント リスナはこのデリゲートをイベント ソースの呼び出しリストに追加します。イベントが発生すると、イベント ハンドラ デリゲートの invoke メソッドが呼び出されます。マルチキャスト イベントの通知とシングルキャスト イベントの通知の両方がサポートされています。Add メソッドと Remove メソッドは、イベントに関連付けられているイベント ハンドラ デリゲート クラスと同様、メタデータでマークする必要があります。
デリゲートは、オブジェクト指向の関数ポインタです。C または C++ では、関数ポインタはメソッドへの参照です。C または C++ の関数ポインタとは異なり、デリゲートは、メソッドへの参照、メソッドをサポートするオブジェクトへの参照という 2 つの参照を保持します。デリゲートは、メソッドを宣言または継承するクラス型がわからなくても、メソッドを呼び出すことができます。デリゲートに必要な情報は、メソッドの戻り値の型とパラメータ リストだけです。
このイベント モデルは、シングルキャスト デリゲートでもマルチキャスト デリゲートでも同じように機能します。デリゲートの invoke メソッドが呼び出された場合、メソッドの呼び出し対象となるオブジェクトは 1 つだけです。マルチキャスト修飾子をデリゲート宣言に適用すると、そのデリゲートの invoke メソッドが呼び出されたときに複数のメソッドを呼び出せるようになります。
GetCustomAttributes の inherit パラメータが true のときに、EventInfo の ICustomAttributeProvider.GetCustomAttributes を呼び出すと、型階層が検索されません。カスタム属性を継承するには、System.Attribute を使用します。
継承時の注意 EventInfo から継承する場合、GetAddMethod、GetRemoveMethod、GetRaiseMethod の各メンバをオーバーライドする必要があります。Imports System Imports System.Reflection Imports System.Security Imports Microsoft.VisualBasic ' Compile this sample using the following command line: ' vbc type_getevent.vb /r:"System.Windows.Forms.dll" /r:"System.dll" Class MyEventExample Public Shared Sub Main() Try ' Creates a bitmask comprising BindingFlags. Dim myBindingFlags As BindingFlags = BindingFlags.Instance Or BindingFlags.Public _ Or BindingFlags.NonPublic Dim myTypeBindingFlags As Type = GetType(System.Windows.Forms.Button) Dim myEventBindingFlags As EventInfo = myTypeBindingFlags.GetEvent("Click", myBindingFlags) If Not (myEventBindingFlags Is Nothing) Then Console.WriteLine("Looking for the Click event in the Button class with the specified BindingFlags.") Console.WriteLine(myEventBindingFlags.ToString()) Else Console.WriteLine("The Click event is not available with the Button class.") End If Catch e As SecurityException Console.WriteLine("An exception occurred.") Console.WriteLine("Message :" + e.Message) Catch e As ArgumentNullException Console.WriteLine("An exception occurred.") Console.WriteLine("Message :" + e.Message) Catch e As Exception Console.WriteLine("The following exception was raised : {0}", e.Message) End Try End Sub 'Main End Class 'MyEventExample
using System; using System.Reflection; using System.Security; class MyEventExample { public static void Main() { try { // Creates a bitmask based on BindingFlags. BindingFlags myBindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Type myTypeBindingFlags = typeof(System.Windows.Forms.Button); EventInfo myEventBindingFlags = myTypeBindingFlags.GetEvent("Click" , myBindingFlags); if(myEventBindingFlags != null) { Console.WriteLine("Looking for the Click event in the Button class with the specified BindingFlags."); Console.WriteLine(myEventBindingFlags.ToString()); } else Console.WriteLine("The Click event is not available with the Button class."); } catch(SecurityException e) { Console.WriteLine("An exception occurred."); Console.WriteLine("Message :"+e.Message); } catch(ArgumentNullException e) { Console.WriteLine("An exception occurred."); Console.WriteLine("Message :"+e.Message); } catch(Exception e) { Console.WriteLine("The following exception was raised : {0}" ,e.Message); } } }
#using <System.dll> #using <System.Windows.Forms.dll> #using <System.Drawing.dll> using namespace System; using namespace System::Reflection; using namespace System::Security; using namespace System::Windows::Forms; int main() { try { // Creates a bitmask based on BindingFlags. BindingFlags myBindingFlags = static_cast<BindingFlags>(BindingFlags::Instance | BindingFlags::Public | BindingFlags::NonPublic); Type^ myTypeBindingFlags = System::Windows::Forms::Button::typeid; EventInfo^ myEventBindingFlags = myTypeBindingFlags->GetEvent( "Click", myBindingFlags ); if ( myEventBindingFlags != nullptr ) { Console::WriteLine( "Looking for the Click event in the Button class with the specified BindingFlags." ); Console::WriteLine( myEventBindingFlags ); } else Console::WriteLine( "The Click event is not available with the Button class." ); } catch ( SecurityException^ e ) { Console::WriteLine( "An exception occurred." ); Console::WriteLine( "Message : {0}", e->Message ); } catch ( ArgumentNullException^ e ) { Console::WriteLine( "An exception occurred." ); Console::WriteLine( "Message : {0}", e->Message ); } catch ( Exception^ e ) { Console::WriteLine( "The following exception was raised : {0}", e->Message ); } }
import System.*; import System.Reflection.*; import System.Security.*; class MyEventExample { public static void main(String[] args) { try { // Creates a bitmask based on BindingFlags. BindingFlags myBindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Type myTypeBindingFlags = System.Windows.Forms.Button.class.ToType(); EventInfo myEventBindingFlags = myTypeBindingFlags.GetEvent("Click" , myBindingFlags); if (myEventBindingFlags != null) { Console.WriteLine("Looking for the Click event in the Button" + " class with the specified BindingFlags."); Console.WriteLine(myEventBindingFlags.ToString()); } else { Console.WriteLine("The Click event is not available with the" + " Button class."); } } catch (SecurityException e) { Console.WriteLine("An exception occurred."); Console.WriteLine("Message :" + e.get_Message()); } catch (ArgumentNullException e) { Console.WriteLine("An exception occurred."); Console.WriteLine("Message :" + e.get_Message()); } catch (System.Exception e) { Console.WriteLine("The following exception was raised : {0}" , e.get_Message()); } } //main } //MyEventExample
System.Reflection.MemberInfo
System.Reflection.EventInfo
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
EventInfo コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)
構文
.NET Framework のセキュリティ
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
EventInfo プロパティ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
DeclaringType | このメンバを宣言するクラスを取得します。 ( MemberInfo から継承されます。) | |
MetadataToken | メタデータ要素を識別する値を取得します。 ( MemberInfo から継承されます。) | |
Module | 現在の MemberInfo によって表されるメンバを宣言する型が定義されているモジュールを取得します。 ( MemberInfo から継承されます。) | |
Name | 現在のメンバの名前を取得します。 ( MemberInfo から継承されます。) | |
ReflectedType | MemberInfo のこのインスタンスを取得するために使用したクラス オブジェクトを取得します。 ( MemberInfo から継承されます。) |
EventInfo メソッド
パブリック メソッド
名前 | 説明 | |
---|---|---|
AddEventHandler | イベント ハンドラをイベント ソースに追加します。 | |
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) | |
GetAddMethod | オーバーロードされます。 イベント ハンドラ デリゲートをイベント ソースに追加するために使用するメソッドを返します。 | |
GetCustomAttributes | オーバーロードされます。 派生クラスによってオーバーライドされた場合、このメンバに適用されているすべての属性を返します。 ( MemberInfo から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) | |
GetOtherMethods | オーバーロードされます。 .other ディレクティブを使用して MSIL 内のイベントに関連付けられたメソッドを返します。 | |
GetRaiseMethod | オーバーロードされます。 イベントの発生時に呼び出されるメソッドを返します。 | |
GetRemoveMethod | オーバーロードされます。 イベント ハンドラ デリゲートをイベント ソースから削除するために使用するメソッドを返します。 | |
GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) | |
IsDefined | 派生クラスによってオーバーライドされた場合、このメンバに attributeType のインスタンスが 1 つ以上適用されているかどうかを示します。 ( MemberInfo から継承されます。) | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) | |
RemoveEventHandler | イベント ハンドラをイベント ソースから削除します。 | |
ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
名前 | 説明 | |
---|---|---|
System.Runtime.InteropServices._EventInfo.GetIDsOfNames | 一連の名前を対応する一連のディスパッチ識別子に割り当てます。 | |
System.Runtime.InteropServices._EventInfo.GetType | EventInfo 型を表す T:System.Type オブジェクトを返します。 | |
System.Runtime.InteropServices._EventInfo.GetTypeInfo | オブジェクトの型情報を取得します。その後は、インターフェイスの型情報の取得に使用できます。 | |
System.Runtime.InteropServices._EventInfo.GetTypeInfoCount | オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。 | |
System.Runtime.InteropServices._EventInfo.Invoke | オブジェクトが公開するプロパティおよびメソッドにアクセスできるようにします。 |
EventInfo メンバ
イベントの属性を取得し、イベントのメタデータにアクセスできるようにします。
EventInfo データ型で公開されるメンバを以下の表に示します。
プロテクト コンストラクタ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
DeclaringType | このメンバを宣言するクラスを取得します。(MemberInfo から継承されます。) | |
MetadataToken | メタデータ要素を識別する値を取得します。(MemberInfo から継承されます。) | |
Module | 現在の MemberInfo によって表されるメンバを宣言する型が定義されているモジュールを取得します。(MemberInfo から継承されます。) | |
Name | 現在のメンバの名前を取得します。(MemberInfo から継承されます。) | |
ReflectedType | MemberInfo のこのインスタンスを取得するために使用したクラス オブジェクトを取得します。(MemberInfo から継承されます。) |
名前 | 説明 | |
---|---|---|
AddEventHandler | イベント ハンドラをイベント ソースに追加します。 | |
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) | |
GetAddMethod | オーバーロードされます。 イベント ハンドラ デリゲートをイベント ソースに追加するために使用するメソッドを返します。 | |
GetCustomAttributes | オーバーロードされます。 派生クラスによってオーバーライドされた場合、このメンバに適用されているすべての属性を返します。 (MemberInfo から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) | |
GetOtherMethods | オーバーロードされます。 .other ディレクティブを使用して MSIL 内のイベントに関連付けられたメソッドを返します。 | |
GetRaiseMethod | オーバーロードされます。 イベントの発生時に呼び出されるメソッドを返します。 | |
GetRemoveMethod | オーバーロードされます。 イベント ハンドラ デリゲートをイベント ソースから削除するために使用するメソッドを返します。 | |
GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) | |
IsDefined | 派生クラスによってオーバーライドされた場合、このメンバに attributeType のインスタンスが 1 つ以上適用されているかどうかを示します。 (MemberInfo から継承されます。) | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) | |
RemoveEventHandler | イベント ハンドラをイベント ソースから削除します。 | |
ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
名前 | 説明 | |
---|---|---|
System.Runtime.InteropServices._EventInfo.GetIDsOfNames | 一連の名前を対応する一連のディスパッチ識別子に割り当てます。 | |
System.Runtime.InteropServices._EventInfo.GetType | EventInfo 型を表す T:System.Type オブジェクトを返します。 | |
System.Runtime.InteropServices._EventInfo.GetTypeInfo | オブジェクトの型情報を取得します。その後は、インターフェイスの型情報の取得に使用できます。 | |
System.Runtime.InteropServices._EventInfo.GetTypeInfoCount | オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。 | |
System.Runtime.InteropServices._EventInfo.Invoke | オブジェクトが公開するプロパティおよびメソッドにアクセスできるようにします。 |
_EventInfo インターフェイス
アセンブリ: mscorlib (mscorlib.dll 内)
構文
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _ <GuidAttribute("9DE59C64-D889-35A1-B897-587D74469E5B")> _ <ComVisibleAttribute(True)> _ <CLSCompliantAttribute(False)> _ Public Interface _EventInfo
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] [GuidAttribute("9DE59C64-D889-35A1-B897-587D74469E5B")] [ComVisibleAttribute(true)] [CLSCompliantAttribute(false)] public interface _EventInfo
[InterfaceTypeAttribute(ComInterfaceType::InterfaceIsIUnknown)] [GuidAttribute(L"9DE59C64-D889-35A1-B897-587D74469E5B")] [ComVisibleAttribute(true)] [CLSCompliantAttribute(false)] public interface class _EventInfo
このインターフェイスは、アンマネージ コードからマネージ クラスにアクセスするためのインターフェイスであるため、マネージ コードからは呼び出さないでください。
このインターフェイスでは、アンマネージ COM オブジェクトでアクセス可能な System.Reflection.EventInfo クラス メンバの vtable の順序が保持されます。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
_EventInfo プロパティ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
Attributes | COM オブジェクトに、Attributes プロパティへのバージョンに依存しないアクセスが用意されています。 | |
DeclaringType | COM オブジェクトに、DeclaringType プロパティへのバージョンに依存しないアクセスが用意されています。 | |
EventHandlerType | COM オブジェクトに、EventHandlerType プロパティへのバージョンに依存しないアクセスが用意されています。 | |
IsMulticast | COM オブジェクトに、IsMulticast プロパティへのバージョンに依存しないアクセスが用意されています。 | |
IsSpecialName | COM オブジェクトに、IsSpecialName プロパティへのバージョンに依存しないアクセスが用意されています。 | |
MemberType | COM オブジェクトに、MemberType プロパティへのバージョンに依存しないアクセスが用意されています。 | |
Name | COM オブジェクトに、Name プロパティへのバージョンに依存しないアクセスが用意されています。 | |
ReflectedType | COM オブジェクトに、ReflectedType プロパティへのバージョンに依存しないアクセスが用意されています。 |
_EventInfo メソッド
パブリック メソッド
_EventInfo メンバ
System.Reflection.EventInfo クラスのパブリック メンバをアンマネージ コードに公開します。
_EventInfo データ型で公開されるメンバを以下の表に示します。
パブリック プロパティ
名前 | 説明 | |
---|---|---|
Attributes | COM オブジェクトに、Attributes プロパティへのバージョンに依存しないアクセスが用意されています。 | |
DeclaringType | COM オブジェクトに、DeclaringType プロパティへのバージョンに依存しないアクセスが用意されています。 | |
EventHandlerType | COM オブジェクトに、EventHandlerType プロパティへのバージョンに依存しないアクセスが用意されています。 | |
IsMulticast | COM オブジェクトに、IsMulticast プロパティへのバージョンに依存しないアクセスが用意されています。 | |
IsSpecialName | COM オブジェクトに、IsSpecialName プロパティへのバージョンに依存しないアクセスが用意されています。 | |
MemberType | COM オブジェクトに、MemberType プロパティへのバージョンに依存しないアクセスが用意されています。 | |
Name | COM オブジェクトに、Name プロパティへのバージョンに依存しないアクセスが用意されています。 | |
ReflectedType | COM オブジェクトに、ReflectedType プロパティへのバージョンに依存しないアクセスが用意されています。 |
- EVENT INFOのページへのリンク