/// <summary> /// Method invoked when (instead of) a new handler is removed from the target event. /// </summary> /// <param name="args">Context information.</param> public override void OnRemoveHandler(EventInterceptionArgs args) { // Remove the handler from our own list. if (RemoveHandler(args.Handler)) { args.RemoveHandler(null); } // Remove the handler from the client. DelegateReferenceKeeper.RemoveReference(args.Handler); }
/// <summary> /// Method invoked when (instead of) a new handler is removed from the target event. /// </summary> /// <param name="args">Context information.</param> public override void OnRemoveHandler(EventInterceptionArgs args) { // Remove the handler from our own list. if (RemoveHandler(args.Handler)) { // If this is the last handler, remove the fake handler to ourselves from the target event. args.RemoveHandler(null); } // Remove the handler from the client. DelegateReferenceKeeper.RemoveReference(args.Handler); }
/// <summary> /// Method invoked when (instead of) a new handler is removed from the target event. /// </summary> /// <param name="args">Context information.</param> public override void OnRemoveHandler(EventInterceptionArgs args) { var weakEventClient = args.Handler.Target as IWeakEventClient; bool supportsWeakReference = weakEventClient != null; // Remove the handler from our own list. if (_weakEventHandler.RemoveHandler(args.Handler)) { // If this is the last handler, remove the fake handler to ourselves from the target event. args.RemoveHandler(null); } // Remove the handler from the client. if (supportsWeakReference) { weakEventClient.UnregisterEventHandler(args.Handler); } }