public GetDelegate ( object callableObject, |
||
callableObject | object | |
delegateType | ||
Результат |
public void AddHandler(object target, object handler, DynamicDelegateCreator delegateCreator) { ContractUtils.RequiresNotNull(handler, "handler"); ContractUtils.RequiresNotNull(delegateCreator, "delegateCreator"); Delegate delegateHandler; HandlerList stubs; // we can add event directly (signature does match): if (_eventInfo.EventHandlerType.IsAssignableFrom(handler.GetType())) { delegateHandler = (Delegate)handler; stubs = null; } else { // create signature converting stub: delegateHandler = delegateCreator.GetDelegate(handler, _eventInfo.EventHandlerType); stubs = GetHandlerList(target); } var add = GetCallableAddMethod(); // TODO (tomat): this used to use event.ReflectedType, is it still correct? if (target != null) { add = CompilerHelpers.TryGetCallableMethod(target.GetType(), add); } add.Invoke(target, new object[] { delegateHandler }); if (stubs != null) { // remember the stub so that we could search for it on removal: stubs.AddHandler(handler, delegateHandler); } }
public void AddHandler(object target, object handler, DynamicDelegateCreator delegateCreator) { ContractUtils.RequiresNotNull(handler, "handler"); ContractUtils.RequiresNotNull(delegateCreator, "delegateCreator"); Delegate delegateHandler; HandlerList stubs; // we can add event directly (signature does match): if (_eventInfo.EventHandlerType.IsAssignableFrom(handler.GetType())) { delegateHandler = (Delegate)handler; stubs = null; } else { // create signature converting stub: delegateHandler = delegateCreator.GetDelegate(handler, _eventInfo.EventHandlerType); stubs = GetHandlerList(target); } GetCallableAddMethod().Invoke(target, new object[] { delegateHandler }); if (stubs != null) { // remember the stub so that we could search for it on removal: stubs.AddHandler(handler, delegateHandler); } }