Esempio n. 1
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     lock (_gate)
     {
         _disposed  = true;
         _observers = ImmutableObserverList.Empty;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObservableAggregateRootEntity"/> class.
        /// </summary>
        protected ObservableAggregateRootEntity()
        {
            _router   = new InstanceEventRouter();
            _recorder = new EventRecorder();

            _observers = ImmutableObserverList.Empty;
            _disposed  = false;
        }
Esempio n. 3
0
 /// <summary>
 /// Subscribes the specified observer to this instance.
 /// </summary>
 /// <param name="observer">The observer.</param>
 /// <returns>A disposable subscription.</returns>
 /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="observer"/> is <c>null</c>.</exception>
 public IDisposable Subscribe(IObserver <object> observer)
 {
     if (observer == null)
     {
         throw new ArgumentNullException("observer");
     }
     lock (_gate)
     {
         ThrowIfDisposed();
         _observers = _observers.Add(observer);
         foreach (var change in GetChanges())
         {
             observer.OnNext(change);
         }
         return(new Subscription(this, observer));
     }
 }