public bool IsFrozen(IDependencyState <T> state) { var targets = TargetsTaken.Where(x => x.Value.Contains(state)) .Select(x => x.Key) .Concat(state.NextTargets) .ToList(); var dependingStates = targets.SelectMany(x => DependanciesTaken.Where(d => d.Key.Equals(x)).SelectMany(d => d.Value).Concat(UnboundedDependancyTaken)); return(dependingStates.Any(x => !x.Equals(state) && !IsCompleted(x))); }
// Reset anything that has taken a dependency on this state public void ResetDependenciesOf(IDependencyState <T> state) { var targets = TargetsTaken.Where(x => x.Value.Contains(state)) .Select(x => x.Key) .ToList(); // Reset bounded dependencies taken foreach (var dependancy in targets.Where(DependanciesTaken.ContainsKey)) { ResetSet(state, DependanciesTaken[dependancy]); } // Reset unbounded dependencies taken ResetSet(state, UnboundedDependancyTaken); // clear targets foreach (var target in targets) { TargetsTaken[target].Remove(state); } }