/// <summary> /// Parses <paramref name="expression"/> into new <see cref="Expressions.Expression"/> object and inserts it into internal data structure. /// </summary> /// <param name="expression">Expression in string format</param> /// <param name="negative">Whether expression result should be negative</param> /// <param name="instanceCreator">Parser instance creator for parsing sub-expressions</param> /// <returns></returns> public ExpressionBuilder Expression(string expression, bool negative, ConstructNewParser instanceCreator) { IExpressionParser parser = instanceCreator.Invoke(); Expression expr = parser.Parse(expression, instanceCreator); expr.Negative = negative; components.AddLast(expr); return(this); }
private IMathComponent[] ConvertToComponents(string[] expressionArray, ConstructNewParser instanceCreator) { IMathComponent[] mathComponents = new IMathComponent[expressionArray.Length]; for (int i = 0; i < expressionArray.Length; i++) { IExpressionParser parser = instanceCreator.Invoke(); Expression expression = parser.Parse(expressionArray[i], instanceCreator); mathComponents[i] = expression; } return(mathComponents); }