예제 #1
0
        private (List <MathOperation> mathOperations, List <decimal> values) PrepareData(string expression)
        {
            List <MathOperation> mathOperations = new List <MathOperation>();
            List <decimal>       values         = new List <decimal>();
            StringBuilder        stringBuilder  = new StringBuilder();

            foreach (char c in expression)
            {
                if (Char.IsDigit(c))
                {
                    stringBuilder.Append(c);
                }
                else
                {
                    mathOperations.Add(MathOperationHelper.ConvertCharToMathOperation(c));
                    values.Add(Decimal.Parse(stringBuilder.ToString()));
                    stringBuilder = new StringBuilder();
                }
            }

            values.Add(Decimal.Parse(stringBuilder.ToString()));
            return(mathOperations, values);
        }
 public OperationToken(char c)
 {
     Operation = MathOperationHelper.ConvertCharToMathOperation(c);
 }