System.Linq.Expressions.Expression.Not C# (CSharp) Method

Not() public static method

Creates a UnaryExpression that represents a bitwise complement operation. The implementing method can be specified.
/// is null. /// is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument. /// is null and the unary not operator is not defined for .Type.-or-.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by .
public static Not ( Expression expression, MethodInfo method ) : UnaryExpression
expression Expression An to set the property equal to.
method System.Reflection.MethodInfo A to set the property equal to.
return UnaryExpression
        public static UnaryExpression Not(Expression expression, MethodInfo method)
        {
            RequiresCanRead(expression, nameof(expression));
            if (method == null)
            {
                if (expression.Type.IsIntegerOrBool())
                {
                    return new UnaryExpression(ExpressionType.Not, expression, expression.Type, null);
                }
                UnaryExpression u = GetUserDefinedUnaryOperator(ExpressionType.Not, "op_LogicalNot", expression);
                if (u != null)
                {
                    return u;
                }
                return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Not, "op_OnesComplement", expression);
            }
            return GetMethodBasedUnaryOperator(ExpressionType.Not, expression, method);
        }

Same methods

Expression::Not ( Expression expression ) : UnaryExpression

Usage Example

Ejemplo n.º 1
0
        protected override object VisitIf(If I)
        {
            string name = target.LabelName();

            LinqExprs.LabelTarget _else = LinqExpr.Label("if_" + name + "_else");
            LinqExprs.LabelTarget end   = LinqExpr.Label("if_" + name + "_end");

            // Check the condition, exit if necessary.
            target.Add(LinqExpr.IfThen(LinqExpr.Not(target.Compile(I.Condition)), LinqExpr.Goto(_else)));

            // Execute true code.
            target.PushScope();
            Visit(I.True);
            target.PopScope();
            target.Add(LinqExpr.Goto(end));

            // Execute false code.
            target.Add(LinqExpr.Label(_else));
            target.PushScope();
            Visit(I.False);
            target.PopScope();

            // Exit point.
            target.Add(LinqExpr.Label(end));
            return(null);
        }
All Usage Examples Of System.Linq.Expressions.Expression::Not
Expression