/// Get the first parameter even if it is wrapped in a parameterList private static EncapsulatedData GetFirstParameter(EncapsulatedData inputData) { if (inputData.type == DataType.ParameterList) { return(inputData.parameterList.First.Value); } else { return(inputData); } }
/// Throw an exception if the function's parameter count doesn't match the expected. private static void CheckParameterCount(EncapsulatedData inputData, int expectedCount) { int realCount = inputData.type == DataType.ParameterList ? inputData.parameterList.Count : 1; if (realCount != expectedCount) { throw new Exception( String.Format( "ParameterCountError: {0} parameters expected, {1} found.", expectedCount, realCount)); } }
public static EncapsulatedData Evaluate(string functionName, EncapsulatedData parameters) { // NOTE parameters.type is not always parameterList. // SubExpressions following single-parameter functions evaluate to EncapsulatedData with a different type. return(FunctionLibrary[functionName](parameters)); }
public SubExpression(EncapsulatedData Evaluated) { this.EvaluatedValue = Evaluated; }
public SubExpression(string functionName, EncapsulatedData parameterList) { // if it is initialized with a string and EncapsulatedData, it is a functioncall which was parsed. this.functionName = functionName; this.parameterList = parameterList; }