CodeDelegateInvokeExpression 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示引发事件的表达式。
public ref class CodeDelegateInvokeExpression : System::CodeDom::CodeExpression
C#
public class CodeDelegateInvokeExpression : System.CodeDom.CodeExpression
C#
[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 调用名为 的事件 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());
C#
// 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 指定要传递给事件的委托的参数。
Code |
初始化 CodeDelegateInvokeExpression 类的新实例。 |
Code |
使用指定的目标对象初始化 CodeDelegateInvokeExpression 类的新实例。 |
Code |
使用指定的目标对象和参数初始化 CodeDelegateInvokeExpression 类的新实例。 |
Parameters |
获取或设置传递到附加于事件的事件处理方法的参数。 |
Target |
获取或设置要调用的事件。 |
User |
获取当前对象的用户可定义数据。 (继承自 CodeObject) |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
产品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |