EventInfo.GetAddMethod 方法

定义

返回用于向事件源添加事件处理程序委托的方法。

重载

GetAddMethod()

返回用于向事件源添加事件处理程序委托的方法。

GetAddMethod(Boolean)

在派生类中重写时,为事件的 AddEventHandler(Object, Delegate) 方法检索 MethodInfo 对象,指定是否返回非公共方法。

GetAddMethod()

返回用于向事件源添加事件处理程序委托的方法。

public:
 System::Reflection::MethodInfo ^ GetAddMethod();
public:
 virtual System::Reflection::MethodInfo ^ GetAddMethod();
public System.Reflection.MethodInfo? GetAddMethod ();
public System.Reflection.MethodInfo GetAddMethod ();
member this.GetAddMethod : unit -> System.Reflection.MethodInfo
abstract member GetAddMethod : unit -> System.Reflection.MethodInfo
override this.GetAddMethod : unit -> System.Reflection.MethodInfo
Public Function GetAddMethod () As MethodInfo

返回

MethodInfo

一个 MethodInfo 对象,表示用于向事件源添加事件处理程序委托的方法。

实现

示例

通常,该方法具有以下签名:

add_<EventName>(<EventHandlerType> handler)  

注解

GetAddMethod 初始化并添加事件订阅方法。 该方法 AddEventHandler 用于向事件源的调用列表添加事件处理程序委托。

另请参阅

适用于

GetAddMethod(Boolean)

在派生类中重写时,为事件的 AddEventHandler(Object, Delegate) 方法检索 MethodInfo 对象,指定是否返回非公共方法。

public:
 abstract System::Reflection::MethodInfo ^ GetAddMethod(bool nonPublic);
public abstract System.Reflection.MethodInfo? GetAddMethod (bool nonPublic);
public abstract System.Reflection.MethodInfo GetAddMethod (bool nonPublic);
abstract member GetAddMethod : bool -> System.Reflection.MethodInfo
Public MustOverride Function GetAddMethod (nonPublic As Boolean) As MethodInfo

参数

nonPublic
Boolean

如果可以返回非公共方法,则为 true;否则为 false

返回

MethodInfo

一个 MethodInfo 对象,表示用于向事件源添加事件处理程序委托的方法。

实现

例外

nonPublictrue,用于添加事件处理程序委托的方法为非公共方法,且调用方没有权限反映非公共方法。

示例

通常,该方法具有以下签名:

add_<EventName>(<EventHandlerType> handler)  

注解

初始化 GetAddMethod 并添加事件订阅方法作为布尔值。 该方法 AddEventHandler 用于向事件源的调用列表添加事件处理程序委托。

另请参阅

适用于