CodeDelegateCreateExpression クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class CodeDelegateCreateExpression Inherits CodeExpression
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class CodeDelegateCreateExpression : CodeExpression
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] public ref class CodeDelegateCreateExpression : public CodeExpression

CodeDelegateCreateExpression は、デリゲートを作成するコードを表します。CodeDelegateCreateExpression は多くの場合、イベントに結び付けるイベント ハンドラやイベントから削除するイベント ハンドラを表す CodeAttachEventStatement や CodeRemoveEventStatement と共に使用されます。
DelegateType プロパティは、作成するデリゲートの型を指定します。TargetObject プロパティは、イベント ハンドラ メソッドを格納するオブジェクトを示します。MethodName プロパティは、メソッド シグネチャが、デリゲートのメソッド シグネチャに一致するイベント ハンドラ メソッドの名前を示します。
C# では、デリゲート作成式は、一般的に new EventHandler(this.HandleEventMethod) という形式になります。Visual Basic では、デリゲート作成式は、一般的に AddressOf Me.HandleEventMethod という形式になります。

CodeDelegateCreateExpression を使用して、デリゲートを作成する方法については、次のコード例を参照してください。
' 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.CodeExpression
System.CodeDom.CodeDelegateCreateExpression


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CodeDelegateCreateExpression クラスのページへのリンク