DataDictionary.Interpreter.Call.GetValue C# (CSharp) Method

GetValue() protected method

Provides the value associated to this Expression
protected GetValue ( DataDictionary.Interpreter.InterpretationContext context, ExplanationPart explain ) : IValue
context DataDictionary.Interpreter.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;

            ExplanationPart subExplanation = ExplanationPart.CreateSubExplanation(explain, this);
            Function function = GetFunction(context, explain);
            if (function != null)
            {
                long start = Environment.TickCount;

                Dictionary<Actual, IValue> parameterValues = AssignParameterValues(context, function, true,
                    subExplanation);
                List<Parameter> parameters = GetPlaceHolders(function, parameterValues);
                if (parameters == null)
                {
                    retVal = function.Evaluate(context, parameterValues, subExplanation);
                    if (retVal == null)
                    {
                        AddErrorAndExplain(
                            "Call " + function.Name + " ( " + ParameterValues(parameterValues) +
                            " ) returned nothing", subExplanation);
                    }
                }
                else if (parameters.Count == 1) // graph
                {
                    int token = context.LocalScope.PushContext();
                    context.LocalScope.SetGraphParameter(parameters[0]);
                    Graph graph = function.CreateGraphForParameter(context, parameters[0], subExplanation);
                    context.LocalScope.PopContext(token);
                    if (graph != null)
                    {
                        retVal = graph.Function;
                    }
                    else
                    {
                        AddError("Cannot create graph on Call " + function.Name + " ( " +
                                 ParameterValues(parameterValues) + " )", RuleChecksEnum.ExecutionFailed);
                    }
                }
                else // surface
                {
                    Surface surface = function.CreateSurfaceForParameters(context, parameters[0], parameters[1],
                        subExplanation);
                    if (surface != null)
                    {
                        retVal = surface.Function;
                    }
                    else
                    {
                        AddError("Cannot create surface on Call " + function.Name + " ( " +
                                 ParameterValues(parameterValues) + " )", RuleChecksEnum.ExecutionFailed);
                    }
                }

                long stop = Environment.TickCount;
                long span = (stop - start);
                function.ExecutionTimeInMilli += span;
                function.ExecutionCount += 1;

                ExplanationPart.SetNamable(subExplanation, retVal);
            }
            else
            {
                AddErrorAndExplain("Cannot find function for " + ToString(), subExplanation);
            }

            return retVal;
        }