Пример #1
0
        /// <summary>
        /// Get the expression operand string.
        /// </summary>
        /// <param name="exp">The expression to return.</param>
        /// <returns>The string expression.</returns>
        public static string GetExpression(Nequeo.Linq.ExpressionOperandBaseType exp)
        {
            switch (exp)
            {
            case Nequeo.Linq.ExpressionOperandBaseType.Add:
                return("+");

            case Nequeo.Linq.ExpressionOperandBaseType.Divide:
                return("/");

            case Nequeo.Linq.ExpressionOperandBaseType.Equal:
                return("==");

            case Nequeo.Linq.ExpressionOperandBaseType.GreaterThan:
                return(">");

            case Nequeo.Linq.ExpressionOperandBaseType.GreaterThanOrEqual:
                return(">=");

            case Nequeo.Linq.ExpressionOperandBaseType.IsFalse:
                return("false");

            case Nequeo.Linq.ExpressionOperandBaseType.IsTrue:
                return("true");

            case Nequeo.Linq.ExpressionOperandBaseType.LessThan:
                return("<");

            case Nequeo.Linq.ExpressionOperandBaseType.LessThanOrEqual:
                return("<=");

            case Nequeo.Linq.ExpressionOperandBaseType.Multiply:
                return("*");

            case Nequeo.Linq.ExpressionOperandBaseType.NotEqual:
                return("!=");

            case Nequeo.Linq.ExpressionOperandBaseType.Subtract:
                return("-");

            case Nequeo.Linq.ExpressionOperandBaseType.And:
                return("&");

            case Nequeo.Linq.ExpressionOperandBaseType.Or:
                return("|");

            case Nequeo.Linq.ExpressionOperandBaseType.AndAlso:
                return("&&");

            case Nequeo.Linq.ExpressionOperandBaseType.OrElse:
                return("||");

            default:
                return("");
            }
        }
Пример #2
0
        /// <summary>
        /// Get the expression type.
        /// </summary>
        /// <param name="exp">The expression to return.</param>
        /// <returns>The expression type.</returns>
        public static ExpressionType GetExpressionType(Nequeo.Linq.ExpressionOperandBaseType exp)
        {
            switch (exp)
            {
            case Nequeo.Linq.ExpressionOperandBaseType.Add:
                return(ExpressionType.Add);

            case Nequeo.Linq.ExpressionOperandBaseType.Divide:
                return(ExpressionType.Divide);

            case Nequeo.Linq.ExpressionOperandBaseType.Equal:
                return(ExpressionType.Equal);

            case Nequeo.Linq.ExpressionOperandBaseType.GreaterThan:
                return(ExpressionType.GreaterThan);

            case Nequeo.Linq.ExpressionOperandBaseType.GreaterThanOrEqual:
                return(ExpressionType.GreaterThanOrEqual);

            case Nequeo.Linq.ExpressionOperandBaseType.IsFalse:
                return(ExpressionType.IsFalse);

            case Nequeo.Linq.ExpressionOperandBaseType.IsTrue:
                return(ExpressionType.IsTrue);

            case Nequeo.Linq.ExpressionOperandBaseType.LessThan:
                return(ExpressionType.LessThan);

            case Nequeo.Linq.ExpressionOperandBaseType.LessThanOrEqual:
                return(ExpressionType.LessThanOrEqual);

            case Nequeo.Linq.ExpressionOperandBaseType.Multiply:
                return(ExpressionType.Multiply);

            case Nequeo.Linq.ExpressionOperandBaseType.NotEqual:
                return(ExpressionType.NotEqual);

            case Nequeo.Linq.ExpressionOperandBaseType.Subtract:
                return(ExpressionType.Subtract);

            case Nequeo.Linq.ExpressionOperandBaseType.And:
                return(ExpressionType.And);

            case Nequeo.Linq.ExpressionOperandBaseType.Or:
                return(ExpressionType.Or);

            case Nequeo.Linq.ExpressionOperandBaseType.AndAlso:
                return(ExpressionType.AndAlso);

            case Nequeo.Linq.ExpressionOperandBaseType.OrElse:
                return(ExpressionType.OrElse);

            default:
                throw new Exception(string.Format("Unhandled expression type: '{0}'", exp.ToString()));
            }
        }
Пример #3
0
        /// <summary>
        /// Create the combined expression.
        /// </summary>
        /// <param name="left">The left expression.</param>
        /// <param name="right">The right expression.</param>
        /// <param name="operand">The joining operand.</param>
        /// <returns>The combined expression.</returns>
        private Expression CreateCombinedExpression(Expression left, Expression right, Nequeo.Linq.ExpressionOperandBaseType operand)
        {
            switch (operand)
            {
            case ExpressionOperandBaseType.Add:
                return(Expression.Add(left, right));

            case ExpressionOperandBaseType.And:
                return(Expression.And(left, right));

            case ExpressionOperandBaseType.AndAlso:
                return(Expression.AndAlso(left, right));

            case ExpressionOperandBaseType.Divide:
                return(Expression.Divide(left, right));

            case ExpressionOperandBaseType.Equal:
                return(Expression.Equal(left, right));

            case ExpressionOperandBaseType.GreaterThan:
                return(Expression.GreaterThan(left, right));

            case ExpressionOperandBaseType.GreaterThanOrEqual:
                return(Expression.GreaterThanOrEqual(left, right));

            case ExpressionOperandBaseType.IsFalse:
                return(Expression.IsFalse(left));

            case ExpressionOperandBaseType.IsTrue:
                return(Expression.IsTrue(left));

            case ExpressionOperandBaseType.LessThan:
                return(Expression.LessThan(left, right));

            case ExpressionOperandBaseType.LessThanOrEqual:
                return(Expression.LessThanOrEqual(left, right));

            case ExpressionOperandBaseType.Multiply:
                return(Expression.Multiply(left, right));

            case ExpressionOperandBaseType.NotEqual:
                return(Expression.NotEqual(left, right));

            case ExpressionOperandBaseType.Or:
                return(Expression.Or(left, right));

            case ExpressionOperandBaseType.OrElse:
                return(Expression.OrElse(left, right));

            case ExpressionOperandBaseType.Subtract:
                return(Expression.Subtract(left, right));

            default:
                return(null);
            }
        }