예제 #1
0
        public override void Recalculate(int depth = 1)
        {
            foreach (var e in DependentOn)
            {
                e.UsedBy.Remove(this);
            }
            DependentOn.Clear();

            _ignoreNotifyElementChanged = true;
            for (var i = 0; i < Exprs.Length; ++i)
            {
                if (Exprs[i] == null)
                {
                    var e = new ScalarExpression(ObjectName, VarName + (i + 1), ExprsStrings[i], i, i == 0, this);
                    Exprs[i]   = e;
                    _values[i] = e.CachedValue;
                }
                else
                {
                    Exprs[i].AllowedToAddToParent = i == 0;
                    Exprs[i].SetRawExpression(ExprsStrings[i]);
                }
                Exprs[i].AllowedToAddToParent = false;
            }
            _ignoreNotifyElementChanged = false;

            NotifyElementChanged();
        }
예제 #2
0
 public void Dealloc()
 {
     foreach (var e in DependentOn)
     {
         e.UsedBy.Remove(this);
     }
     DependentOn.Clear();
 }
예제 #3
0
        public override void Recalculate(int depth = 1)
        {
            if (depth > MaxRecursionDepth)
            {
                // we are proabaly about to encounter a stack overflow
                return;
            }
            // remove all the DependentOn values
            // e.g. remove the cross-references
            foreach (var e in DependentOn)
            {
                e.UsedBy.Remove(this);
            }
            DependentOn.Clear();

            try
            {
                var val = Evaluater.Evaluate(ExprString, VarEval, IndexInArray);
                CachedValue.SwitchTo(val.IsArray ? val.AsArray[IndexInArray] : val);
            }
            catch
            {
                StepManager.ErrorOccurred = true;
            }

            if (!IsWeak)
            {
                if (UsedBy.Count > 0)
                {
                    var copyOfUsedBy = new List <Expression>(UsedBy);
                    UsedBy.Clear();
                    foreach (var e in copyOfUsedBy)
                    {
                        e.Recalculate(depth + 1);
                    }
                }
                ParentArray?.NotifyElementChanged();
            }
            ValueChanged?.Invoke(this, EventArgs.Empty);
        }