Exemplo n.º 1
0
        public virtual string EvalText(string format)
        {
            if (Operand1 == null || Operand2 == null)
            {
                throw new OperandException(Name);
            }
            StringBuilder sb = new StringBuilder();

            if (Operand1 != null)
            {
                if (Operand1 is InfixOperationToken && ((InfixOperationToken)Operand1).Precedence < Precedence)
                {
                    sb.AppendFormat("({0})", Operand1.EvalText(format));
                }
                else
                {
                    sb.Append(Operand1.EvalText(format));
                }
            }
            else
            {
                sb.Append("[Missing]");
            }
            sb.Append(' ').Append(Name).Append(' ');
            if (Operand2 != null)
            {
                if (Operand2 is InfixOperationToken && ((InfixOperationToken)Operand2).Precedence <= Precedence)
                {
                    sb.AppendFormat("({0})", Operand2.EvalText(format));
                }
                else
                {
                    sb.Append(Operand2.EvalText(format));
                }
            }
            else
            {
                sb.Append("[Missing]");
            }
            return(sb.ToString());
        }