DataDictionary.Interpreter.ListOperators.SumExpression.GetValue C# (CSharp) Method

GetValue() protected method

Provides the value associated to this Expression
protected GetValue ( InterpretationContext context, ExplanationPart explain ) : IValue
context InterpretationContext The context on which the value must be found
explain ExplanationPart The explanation to fill, if any
return IValue
        protected internal override IValue GetValue(InterpretationContext context, ExplanationPart explain)
        {
            IValue retVal = null;

            ListValue value = ListExpression.GetValue(context, explain) as ListValue;
            if (value != null)
            {
                int token = PrepareIteration(context);
                context.LocalScope.SetVariable(AccumulatorVariable);

                Type resultType = GetExpressionType();
                if (resultType != null)
                {
                    AccumulatorVariable.Value = resultType.getValue("0");
                    foreach (IValue v in value.Val)
                    {
                        if (v != EfsSystem.Instance.EmptyValue)
                        {
                            // All elements should always be != from EmptyValue
                            ElementFound = true;
                            IteratorVariable.Value = v;
                            if (ConditionSatisfied(context, explain))
                            {
                                MatchingElementFound = true;
                                AccumulatorVariable.Value = Accumulator.GetValue(context, explain);
                            }
                        }
                        NextIteration();
                    }
                }
                EndIteration(context, explain, token);

                retVal = AccumulatorVariable.Value;
            }

            return retVal;
        }