Пример #1
0
        public void NotifyElementChanged()
        {
            if (_ignoreNotifyElementChanged)
            {
                return;
            }
            if (UsedBy.Count > 0)
            {
                var copyOfUsedBy = new List <Expression>(UsedBy);
                UsedBy.Clear();
                foreach (var e in copyOfUsedBy)
                {
                    var ae = e as ArrayExpression;
                    ae?.SetRawExpression(ae.ExprString, Exprs.Length);
                    e.Recalculate();
                }
            }

            ValueChanged?.Invoke(this, EventArgs.Empty);
        }
Пример #2
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);
        }