CodeAttachEventStatement クラス
アセンブリ: System (system.dll 内)
構文<SerializableAttribute> _ <ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class CodeAttachEventStatement Inherits CodeStatement
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class CodeAttachEventStatement : CodeStatement
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] public ref class CodeAttachEventStatement : public CodeStatement
解説CodeAttachEventStatement を使用して、イベント ハンドラのデリゲートをイベントに追加するステートメントを表すことができます。Event プロパティは、イベント ハンドラを結び付けるイベントを表します。Listener プロパティは、結びつけるイベント ハンドラを表します。
使用例CodeAttachEventStatement を使用してイベント ハンドラをイベントに結び付ける方法を示すコード例を次に示します。
' Defines a delegate creation expression that creates an EventHandler delegate pointing to TestMethod. Dim createDelegate1 As New CodeDelegateCreateExpression(New CodeTypeReference("System.EventHandler"), New CodeThisReferenceExpression(), "TestMethod") ' Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event. Dim attachStatement1 As New CodeAttachEventStatement(New CodeThisReferenceExpression(), "TestEvent", createDelegate1) ' A Visual Basic code generator produces the following source code for the preceeding example code: ' AddHandler TestEvent, AddressOf Me.TestMethod
// Defines a delegate creation expression that creates an EventHandler delegate pointing to a method named TestMethod. CodeDelegateCreateExpression createDelegate1 = new CodeDelegateCreateExpression( new CodeTypeReference( "System.EventHandler" ), new CodeThisReferenceExpression(), "TestMethod" ); // Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event. CodeAttachEventStatement attachStatement1 = new CodeAttachEventStatement( new CodeThisReferenceExpression(), "TestEvent", createDelegate1 ); // A C# code generator produces the following source code for the preceeding example code: // this.TestEvent += new System.EventHandler(this.TestMethod);
// Defines a delegate creation expression that creates an EventHandler delegate pointing to a method named TestMethod. CodeDelegateCreateExpression^ createDelegate1 = gcnew CodeDelegateCreateExpression( gcnew CodeTypeReference( "System.EventHandler" ),gcnew CodeThisReferenceExpression,"TestMethod" ); // Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event. CodeAttachEventStatement^ attachStatement1 = gcnew CodeAttachEventStatement( gcnew CodeThisReferenceExpression,"TestEvent",createDelegate1 ); // A C# code generator produces the following source code for the preceeding example code: // this.TestEvent += new System.EventHandler(this.TestMethod);
// Defines a delegate creation expression that creates an EventHandler // delegate pointing to a method named TestMethod. CodeDelegateCreateExpression createDelegate1 = new CodeDelegateCreateExpression(new CodeTypeReference ("System.EventHandler"), new CodeThisReferenceExpression() , "TestMethod"); // Attaches an EventHandler delegate pointing to TestMethod to the // TestEvent event. CodeAttachEventStatement attachStatement1 = new CodeAttachEventStatement(new CodeThisReferenceExpression() , "TestEvent", createDelegate1); // A VJ# code generator produces the following source code for the // preceeding example code: // this.add_TestEvent(new System.EventHandler(this.TestMethod));
継承階層System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeAttachEventStatement
スレッド セーフ
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照CodeAttachEventStatement コンストラクタ ()
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照CodeAttachEventStatement コンストラクタ (CodeEventReferenceExpression, CodeExpression)
アセンブリ: System (system.dll 内)
構文Dim eventRef As CodeEventReferenceExpression Dim listener As CodeExpression Dim instance As New CodeAttachEventStatement(eventRef, listener)
public: CodeAttachEventStatement ( CodeEventReferenceExpression^ eventRef, CodeExpression^ listener )
public function CodeAttachEventStatement ( eventRef : CodeEventReferenceExpression, listener : CodeExpression )
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照CodeAttachEventStatement コンストラクタ (CodeExpression, String, CodeExpression)
アセンブリ: System (system.dll 内)
構文Public Sub New ( _ targetObject As CodeExpression, _ eventName As String, _ listener As CodeExpression _ )
Dim targetObject As CodeExpression Dim eventName As String Dim listener As CodeExpression Dim instance As New CodeAttachEventStatement(targetObject, eventName, listener)
public CodeAttachEventStatement ( CodeExpression targetObject, string eventName, CodeExpression listener )
public: CodeAttachEventStatement ( CodeExpression^ targetObject, String^ eventName, CodeExpression^ listener )
public CodeAttachEventStatement ( CodeExpression targetObject, String eventName, CodeExpression listener )
public function CodeAttachEventStatement ( targetObject : CodeExpression, eventName : String, listener : CodeExpression )
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照CodeAttachEventStatement コンストラクタ
オーバーロードの一覧| 名前 | 説明 |
|---|---|
| CodeAttachEventStatement () | CodeAttachEventStatement クラスの新しいインスタンスを初期化します。 |
| CodeAttachEventStatement (CodeEventReferenceExpression, CodeExpression) | イベントとデリゲートを指定して、CodeAttachEventStatement クラスの新しいインスタンスを初期化します。 |
| CodeAttachEventStatement (CodeExpression, String, CodeExpression) | イベント、イベント名、およびイベント ハンドラ デリゲートを格納しているオブジェクトを指定して、CodeAttachEventStatement クラスの新しいインスタンスを初期化します。 |
参照CodeAttachEventStatement プロパティ
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| EndDirectives | 終了ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。 ( CodeStatement から継承されます。) |
| Event | イベント ハンドラ デリゲートを結び付けるイベントを取得または設定します。 |
| LinePragma | コード ステートメントのある行を取得または設定します。 ( CodeStatement から継承されます。) |
| Listener | イベントに結び付ける新しいイベント ハンドラのデリゲートを取得または設定します。 |
| StartDirectives | 開始ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。 ( CodeStatement から継承されます。) |
| UserData | 現在のオブジェクトのユーザー定義可能なデータを取得または設定します。 ( CodeObject から継承されます。) |
参照CodeAttachEventStatement メソッド
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
| ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
参照CodeAttachEventStatement メンバ
イベント ハンドラのデリゲートをイベントに結び付けるステートメントを表します。
CodeAttachEventStatement データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| EndDirectives | 終了ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。(CodeStatement から継承されます。) |
| Event | イベント ハンドラ デリゲートを結び付けるイベントを取得または設定します。 |
| LinePragma | コード ステートメントのある行を取得または設定します。 (CodeStatement から継承されます。) |
| Listener | イベントに結び付ける新しいイベント ハンドラのデリゲートを取得または設定します。 |
| StartDirectives | 開始ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。(CodeStatement から継承されます。) |
| UserData | 現在のオブジェクトのユーザー定義可能なデータを取得または設定します。(CodeObject から継承されます。) |
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
| ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
参照- CodeAttachEventStatementのページへのリンク