CodeDelegateCreateExpression クラス

定義

デリゲートを作成する式を表します。

public ref class CodeDelegateCreateExpression : System::CodeDom::CodeExpression
public class CodeDelegateCreateExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeDelegateCreateExpression : System.CodeDom.CodeExpression
type CodeDelegateCreateExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeDelegateCreateExpression = class
    inherit CodeExpression
Public Class CodeDelegateCreateExpression
Inherits CodeExpression
継承
CodeDelegateCreateExpression
属性

次のコード例では、a を CodeDelegateCreateExpression 使用してデリゲートを作成します。

// 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 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 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

注釈

CodeDelegateCreateExpression は、デリゲートを作成するコードを表します。 CodeDelegateCreateExpressionは、多くの場合、イベントのアタッチまたはCodeRemoveEventStatement削除を行うイベント ハンドラーと共CodeAttachEventStatementに、またはイベント ハンドラーを表すために使用されます。

このプロパティは DelegateType 、作成するデリゲートの型を指定します。 このプロパティは TargetObject 、イベント ハンドラー メソッドを含むオブジェクトを示します。 このプロパティは MethodName 、デリゲートのメソッド シグネチャと一致するメソッド シグネチャを持つイベント ハンドラー メソッドの名前を示します。

C# では、デリゲートの作成式は通常、次の形式 new EventHandler(this.HandleEventMethod)です。 Visual Basicでは、デリゲートの作成式は通常、次の形式AddressOf Me.HandleEventMethodです。

コンストラクター

CodeDelegateCreateExpression()

CodeDelegateCreateExpression クラスの新しいインスタンスを初期化します。

CodeDelegateCreateExpression(CodeTypeReference, CodeExpression, String)

CodeDelegateCreateExpression クラスの新しいインスタンスを初期化します。

プロパティ

DelegateType

デリゲートのデータ型を取得または設定します。

MethodName

イベント ハンドラー メソッドの名前を取得または設定します。

TargetObject

イベント ハンドラー メソッドを格納するオブジェクトを取得または設定します。

UserData

現在のオブジェクトのユーザー定義可能なデータを取得します。

(継承元 CodeObject)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

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

(継承元 Object)
MemberwiseClone()

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

(継承元 Object)
ToString()

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

(継承元 Object)

適用対象