IsTrue() public static méthode

Returns whether the expression evaluates to true.
public static IsTrue ( Expression expression ) : UnaryExpression
expression Expression An to evaluate.
Résultat UnaryExpression
Exemple #1
0
        public static Expression And(IEnumerable <Expression> expressions, ParameterExpression parameterExpression)
        {
            Expression overallExpression = Expression.IsTrue(Expression.Constant(true, typeof(bool)));

            if (expressions.Count() == 1)
            {
                overallExpression = expressions.First();
            }

            if (expressions.Count() > 1)
            {
                Expression?start = null;
                foreach (var expression in expressions)
                {
                    start = start == null
                        ? expression
                        : Expression.AndAlso(start, expression);
                }
                if (start != null)
                {
                    overallExpression = start !;
                }
            }

            return(overallExpression);
        }
        private UnaryExpression UnaryExpression(
            ExpressionType nodeType, System.Type type, JObject obj)
        {
            var operand = this.Prop(obj, "operand", this.Expression);
            var method  = this.Prop(obj, "method", this.Method);

            switch (nodeType)
            {
            case ExpressionType.ArrayLength: return(Expr.ArrayLength(operand));

            case ExpressionType.Convert: return(Expr.Convert(operand, type, method));

            case ExpressionType.ConvertChecked: return(Expr.ConvertChecked(operand, type, method));

            case ExpressionType.Decrement: return(Expr.Decrement(operand, method));

            case ExpressionType.Increment: return(Expr.Increment(operand, method));

            case ExpressionType.IsFalse: return(Expr.IsFalse(operand, method));

            case ExpressionType.IsTrue: return(Expr.IsTrue(operand, method));

            case ExpressionType.Negate: return(Expr.Negate(operand, method));

            case ExpressionType.NegateChecked: return(Expr.NegateChecked(operand, method));

            case ExpressionType.Not: return(Expr.Not(operand, method));

            case ExpressionType.OnesComplement: return(Expr.OnesComplement(operand, method));

            case ExpressionType.PostDecrementAssign: return(Expr.PostDecrementAssign(operand, method));

            case ExpressionType.PostIncrementAssign: return(Expr.PostIncrementAssign(operand, method));

            case ExpressionType.PreDecrementAssign: return(Expr.PreDecrementAssign(operand, method));

            case ExpressionType.PreIncrementAssign: return(Expr.PreIncrementAssign(operand, method));

            case ExpressionType.Quote: return(Expr.Quote(operand));

            case ExpressionType.Throw: return(Expr.Throw(operand, type));

            case ExpressionType.TypeAs: return(Expr.TypeAs(operand, type));

            case ExpressionType.UnaryPlus: return(Expr.UnaryPlus(operand, method));

            case ExpressionType.Unbox: return(Expr.Unbox(operand, type));

            default: throw new NotSupportedException();
            }
        }
Exemple #3
0
 public void UnaryExpression_IsTrue() => ExecuteExpr(Property.Active, active => Expr.Equal(active, Expr.IsTrue(Expr.Constant(true))), ExpressionType.IsTrue, "filter_active=-1");