<PackageReference Include="System.Reactive" Version="4.2.0" />

EventPatternSourceBase<TSender, TEventArgs>

public abstract class EventPatternSourceBase<TSender, TEventArgs>
Base class for classes that expose an observable sequence as a well-known event pattern (sender, event arguments). Contains functionality to maintain a map of event handler delegates to observable sequence subscriptions. Subclasses should only add an event with custom add and remove methods calling into the base class's operations.
protected EventPatternSourceBase(IObservable<EventPattern<TSender, TEventArgs>> source, Action<Action<TSender, TEventArgs>, EventPattern<TSender, TEventArgs>> invokeHandler)

Creates a new event pattern source.

protected void Add(Delegate handler, Action<TSender, TEventArgs> invoke)

Adds the specified event handler, causing a subscription to the underlying source.

protected void Remove(Delegate handler)

Removes the specified event handler, causing a disposal of the corresponding subscription to the underlying source that was created during the Add operation.