public void AddHandler(object target, object handler, LanguageContext language) { ContractUtils.RequiresNotNull(handler, "handler"); ContractUtils.RequiresNotNull(language, "language"); 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 = language.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); } }