CodeDelegateInvokeExpression 类

定义

表示引发事件的表达式。Represents an expression that raises an event.

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

示例

下面的示例演示CodeDelegateInvokeExpression如何使用调用名为TestEvent的事件。The following example demonstrates use of a CodeDelegateInvokeExpression to invoke an event named 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可用于表示调用事件的代码。CodeDelegateInvokeExpression can be used to represent code that invokes an event. 调用事件将使用指定的参数调用注册到事件的所有委托。Invoking an event invokes all delegates that are registered with the event using the specified parameters.

TargetObject属性指定要调用的事件。The TargetObject property specifies the event to invoke. Parameters属性指定要传递给事件的委托的参数。The Parameters property specifies the parameters to pass to the delegates for the event.

构造函数

CodeDelegateInvokeExpression()

初始化 CodeDelegateInvokeExpression 类的新实例。Initializes a new instance of the CodeDelegateInvokeExpression class.

CodeDelegateInvokeExpression(CodeExpression)

使用指定的目标对象初始化 CodeDelegateInvokeExpression 类的新实例。Initializes a new instance of the CodeDelegateInvokeExpression class using the specified target object.

CodeDelegateInvokeExpression(CodeExpression, CodeExpression[])

使用指定的目标对象和参数初始化 CodeDelegateInvokeExpression 类的新实例。Initializes a new instance of the CodeDelegateInvokeExpression class using the specified target object and parameters.

属性

Parameters

获取或设置传递到附加于事件的事件处理方法的参数。Gets or sets the parameters to pass to the event handling methods attached to the event.

TargetObject

获取或设置要调用的事件。Gets or sets the event to invoke.

UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅