CodeDelegateInvokeExpression 類別

定義

表示引發事件的運算式。

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

範例

下列範例示範如何使用 CodeDelegateInvokeExpression 叫用名為 TestEvent的事件。

// Invokes the delegates for an event named TestEvent, passing a local object reference and a new System.EventArgs.
array<CodeExpression^>^temp1 = {gcnew CodeThisReferenceExpression,gcnew CodeObjectCreateExpression( "System.EventArgs", nullptr )};
CodeDelegateInvokeExpression^ invoke1 = gcnew CodeDelegateInvokeExpression( gcnew CodeEventReferenceExpression( gcnew CodeThisReferenceExpression,"TestEvent" ),temp1 );

// A C# code generator produces the following source code for the preceeding example code:
//    this.TestEvent(this, new System.EventArgs());
// Invokes the delegates for an event named TestEvent, passing a local object reference and a new System.EventArgs.
CodeDelegateInvokeExpression invoke1 = new CodeDelegateInvokeExpression( new CodeEventReferenceExpression(new CodeThisReferenceExpression(), "TestEvent"),
    new CodeExpression[] { new CodeThisReferenceExpression(), new CodeObjectCreateExpression("System.EventArgs") } );

// A C# code generator produces the following source code for the preceeding example code:

//    this.TestEvent(this, new System.EventArgs());
' Invokes the delegates for an event named TestEvent, passing a local object reference and a new System.EventArgs.
Dim invoke1 As New CodeDelegateInvokeExpression( _
    New CodeEventReferenceExpression(New CodeThisReferenceExpression(), "TestEvent"), _
    New CodeExpression() {New CodeThisReferenceExpression(), New CodeObjectCreateExpression("System.EventArgs")})

' A Visual Basic code generator produces the following source code for the preceeding example code:

'   RaiseEvent TestEvent(Me, New System.EventArgs())

備註

CodeDelegateInvokeExpression 可用來表示叫用事件的程序代碼。 叫用事件會叫用使用指定參數向事件註冊的所有委派。

屬性 TargetObject 會指定要叫用的事件。 屬性 Parameters 會指定要傳遞至事件委派的參數。

建構函式

CodeDelegateInvokeExpression()

初始化 CodeDelegateInvokeExpression 類別的新執行個體。

CodeDelegateInvokeExpression(CodeExpression)

使用指定的目標物件來初始化 CodeDelegateInvokeExpression 類別的新執行個體。

CodeDelegateInvokeExpression(CodeExpression, CodeExpression[])

使用指定的目標物件和參數來初始化 CodeDelegateInvokeExpression 類別的新執行個體。

屬性

Parameters

取得或設定參數,傳遞至附加到事件之事件處理常式方法。

TargetObject

取得或設定要叫用的事件。

UserData

取得目前物件的使用者可定義資料。

(繼承來源 CodeObject)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱