/// <summary> /// Adds a handler to an event. /// </summary> /// <param name="handler">The handler to be added.</param> /// <returns>The original event with handler added.</returns> private object InPlaceAdd(object handler) { Requires.NotNull(handler, nameof(handler)); VerifyHandler(handler); ComEventsSink comEventSink = ComEventsSink.FromRuntimeCallableWrapper(_rcw, _sourceIid, true); comEventSink.AddHandler(_dispid, handler); return(this); }
/// <summary> /// Removes handler from the event. /// </summary> /// <param name="handler">The handler to be removed.</param> /// <returns>The original event with handler removed.</returns> private object InPlaceSubtract(object handler) { Requires.NotNull(handler, nameof(handler)); VerifyHandler(handler); ComEventsSink comEventSink = ComEventsSink.FromRuntimeCallableWrapper(_rcw, _sourceIid, false); comEventSink?.RemoveHandler(_dispid, handler); return(this); }