Share via


CodeDelegateCreateExpression Sınıf

Tanım

Temsilci oluşturan bir ifadeyi temsil eder.

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
Devralma
CodeDelegateCreateExpression
Öznitelikler

Örnekler

Aşağıdaki örnek kod, temsilci oluşturmak için bir CodeDelegateCreateExpression kullanır.

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

Açıklamalar

CodeDelegateCreateExpression bir temsilci oluşturan kodu temsil eder. CodeDelegateCreateExpression genellikle veya ile bir CodeAttachEventStatementCodeRemoveEventStatement olay işleyicisini temsil etmek için kullanılır ve bir olayı eklemek veya olaydan kaldırmak için kullanılır.

DelegateType özelliği oluşturulacak temsilci türünü belirtir. özelliği, TargetObject olay işleyicisi yöntemini içeren nesneyi gösterir. özelliği, MethodName yöntem imzası temsilcinin yöntem imzası ile eşleşen olay işleyicisi yönteminin adını gösterir.

C# dilinde temsilci oluşturma ifadesi genellikle şu biçimdedir: new EventHandler(this.HandleEventMethod). Visual Basic'te temsilci oluşturma ifadesi genellikle şu biçimdedir: AddressOf Me.HandleEventMethod.

Oluşturucular

CodeDelegateCreateExpression()

CodeDelegateCreateExpression sınıfının yeni bir örneğini başlatır.

CodeDelegateCreateExpression(CodeTypeReference, CodeExpression, String)

CodeDelegateCreateExpression sınıfının yeni bir örneğini başlatır.

Özellikler

DelegateType

Temsilcinin veri türünü alır veya ayarlar.

MethodName

Olay işleyicisi yönteminin adını alır veya ayarlar.

TargetObject

Olay işleyicisi yöntemini içeren nesneyi alır veya ayarlar.

UserData

Geçerli nesne için kullanıcı tarafından tanımlanabilir verileri alır.

(Devralındığı yer: CodeObject)

Yöntemler

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır