Beispiel #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="calculator"></param>
        /// <param name="el"></param>
        /// <param name="option"></param>
        /// <returns></returns>
        public static CalculatorToken CreateCalculatorToken(Calculator calculator, XmlNode el, SaveOption option)
        {
            CalculatorToken token;

            CalculatorTokenType type = (CalculatorTokenType)int.Parse(el.Attributes["type"].Value);

            switch (type)
            {
                case CalculatorTokenType.BinaryOperator:
                    token = new CalculatorTokenBinaryOperator(calculator, el, option);
                    break;

                case CalculatorTokenType.Keyword:
                    token = new CalculatorTokenKeyword(calculator, el, option);
                    break;

                /*case CalculatorTokenType.UnaryOperator:
                    token = new CalculatorTokenUnaryOperator(el, option);
                    break;*/

                case CalculatorTokenType.Value:
                    token = new CalculatorTokenValue(calculator, el, option);
                    break;

                case CalculatorTokenType.Function:
                    token = new CalculatorTokenFunction(calculator, el, option);
                    break;

                default:
                    throw new InvalidOperationException("unknown CalculatorTokenType");
            }

            return token;
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="calculator"></param>
        /// <param name="br"></param>
        /// <param name="option"></param>
        /// <returns></returns>
        public static CalculatorToken CreateCalculatorToken(Calculator calculator, BinaryReader br, SaveOption option)
        {
            CalculatorToken token;

            CalculatorTokenType type = (CalculatorTokenType)br.ReadInt32();

            switch (type)
            {
                case CalculatorTokenType.BinaryOperator:
                    token = new CalculatorTokenBinaryOperator(calculator, br, option);
                    break;

                case CalculatorTokenType.Keyword:
                    token = new CalculatorTokenKeyword(calculator, br, option);
                    break;

                /*case CalculatorTokenType.UnaryOperator:
                    token = new CalculatorTokenUnaryOperator(el, option);
                    break;*/

                case CalculatorTokenType.Value:
                    token = new CalculatorTokenValue(calculator, br, option);
                    break;

                case CalculatorTokenType.Function:
                    token = new CalculatorTokenFunction(calculator, br, option);
                    break;

                default:
                    throw new InvalidOperationException("unknown CalculatorTokenType");
            }

            return token;
        }