/// <inheritdoc /> public IDisposable Subscribe(IObserver <RedirectionContext> observer) { Observers.Add(observer); // Optionally start the redirection, in case it wasn't redirecting calls UnderlyingRedirection.Start(); return(new Disposable(this, observer)); }
/// <summary> /// Unsubscribes the given <paramref name="observer"/>. /// </summary> private void Unsubscribe(IObserver <RedirectionContext> observer) { Observers.Remove(observer); if (Observers.Count == 0) { // Stop the redirection, since noone is there to handle it. UnderlyingRedirection.Stop(); } }
/// <inheritdoc /> public override void Dispose() { UnderlyingRedirection.Dispose(); ObservingRedirections.Remove(Key); }