コード例 #1
0
 public void AddExpressionDependingOnMe(IReactiveExpression reactiveExpression)
 {
     if (_expressionsDependingOnMe == null)
     {
         _expressionsDependingOnMe = new List <IReactiveExpression>();
     }
     _expressionsDependingOnMe.Add(reactiveExpression);
 }
コード例 #2
0
        internal IReactive[] UpdateExpressionDependencies(IReactive[] oldDependencies, IReactiveExpression reactiveExpression)
        {
            if (_nextDependencyIndex < _currentDependencies.Length)
            {
                if (_newDependencies != null)
                {
                    throw new Exception("_newDependencies unexpectedly initialized when _nextDependencyIndex is before the end");
                }

                _newDependencies = new List <IReactive>();
                for (int i = 0; i < _nextDependencyIndex; ++i)
                {
                    _newDependencies.Add(_currentDependencies[i]);
                }
            }

            IReactive[] newDependenciesArray = _newDependencies !.ToArray();

            var currDependenciesSet = new HashSet <IReactive>();

            foreach (IReactive currDependency in oldDependencies)
            {
                currDependenciesSet.Add(currDependency);
            }

            var newDependenciesSet = new HashSet <IReactive>();

            foreach (IReactive newDependency in newDependenciesArray)
            {
                newDependenciesSet.Add(newDependency);
            }

            // TODO: Catch exceptions here to ensure in consistent state
            foreach (IReactive removeDependency in currDependenciesSet.Except(newDependenciesSet))
            {
                removeDependency.RemoveExpressionDependingOnMe(reactiveExpression);
            }

            foreach (IReactive addDependency in newDependenciesArray.Except(currDependenciesSet))
            {
                addDependency.AddExpressionDependingOnMe(reactiveExpression);
            }

            return(newDependenciesArray);
        }
コード例 #3
0
 public void RemoveExpressionDependingOnMe(IReactiveExpression reactiveExpression)
 {
     _expressionsDependingOnMe?.Remove(reactiveExpression);
 }