示例#1
0
        /// <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));
        }
示例#2
0
        /// <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();
            }
        }
示例#3
0
 /// <inheritdoc />
 public override void Dispose()
 {
     UnderlyingRedirection.Dispose();
     ObservingRedirections.Remove(Key);
 }