本文整理汇总了C#中EventHandler.GetMethodInfo方法的典型用法代码示例。如果您正苦于以下问题:C# EventHandler.GetMethodInfo方法的具体用法?C# EventHandler.GetMethodInfo怎么用?C# EventHandler.GetMethodInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler.GetMethodInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WeakEventSubscription
/// <summary>
/// Initializes a new instance of the <see cref="WeakEventSubscription"/> class.
/// </summary>
/// <param name="target">The event handler's owner.</param>
/// <param name="eventHandler">The event handler.</param>
/// <param name="subscribeAction">The action to subscribe the event handler.</param>
/// <param name="unsubscribeAction">The action to unsubscribe the event handler.</param>
public WeakEventSubscription(object target, EventHandler eventHandler, Action<EventHandler> subscribeAction, Action<EventHandler> unsubscribeAction)
{
_unsubscribeAction = unsubscribeAction;
Method = eventHandler.GetMethodInfo();
EventHandlerReference = new WeakReference(eventHandler.Target);
Reference = new WeakReference(target);
subscribeAction(OnEvent);
}
示例2: UnsubscribeFromStoppingNotifcation
public void UnsubscribeFromStoppingNotifcation(object handlerObject, EventHandler<object> handler)
{
var handlerDelegate = Delegate.CreateDelegate(stoppingEvent.EventHandlerType, handlerObject, handler.GetMethodInfo());
stoppingEventRemove.Invoke(null, new[] { handlerDelegate });
}
示例3: SubscribeForStoppingNotifcation
public void SubscribeForStoppingNotifcation(object handlerObject, EventHandler<object> handler)
{
var handlerDelegate = handler.GetMethodInfo().CreateDelegate(stoppingEvent.EventHandlerType, handlerObject);
stoppingEventAdd.Invoke(null, new object[] { handlerDelegate });
}