protected virtual void Dispose(bool disposing) { if (disposing) { if (_subscriptions.Any()) { foreach (var subscription in _subscriptions) { subscription.Dispose(); } _subscriptions.Clear(); } if (_prerequisites.Any()) { _prerequisites.Dispose(); } } }
/// <summary> /// When composing conditions this takes a collection of subconditions. /// </summary> /// <param name="prerequisites"></param> protected Condition(ConditionCollection prerequisites) { this.Name = this.GetType().Name; if (prerequisites != null && prerequisites.Any()) { _prerequisites = prerequisites; var subscription = _prerequisites.ToObservable(x => x.IsSatisfied, false) .Subscribe(x => this.UpdateIsSatisfied()); _subscriptions.Add(subscription); this.UpdateIsSatisfied(); } }