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

Invoke() static private method

Creates an InvocationExpression that applies a delegate or lambda expression to three argument expressions.
/// is null. /// .Type does not represent a delegate type or an .-or-The property of an argument expression is not assignable to the type of the corresponding parameter of the delegate represented by . /// The number of arguments does not contain match the number of parameters for the delegate represented by .
static private Invoke ( Expression expression, Expression arg0, Expression arg1, Expression arg2 ) : InvocationExpression
expression Expression /// An that represents the delegate /// or lambda expression to be applied. ///
arg0 Expression /// The that represents the first argument. ///
arg1 Expression /// The that represents the second argument. ///
arg2 Expression /// The that represents the third argument. ///
return InvocationExpression
        internal static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1, Expression arg2)
        {
            // NB: This method is marked as non-public to avoid public API additions at this point.

            RequiresCanRead(expression, nameof(expression));

            MethodInfo method = GetInvokeMethod(expression);

            ParameterInfo[] pis = GetParametersForValidation(method, ExpressionType.Invoke);

            ValidateArgumentCount(method, ExpressionType.Invoke, 3, pis);

            arg0 = ValidateOneArgument(method, ExpressionType.Invoke, arg0, pis[0], nameof(expression), nameof(arg0));
            arg1 = ValidateOneArgument(method, ExpressionType.Invoke, arg1, pis[1], nameof(expression), nameof(arg1));
            arg2 = ValidateOneArgument(method, ExpressionType.Invoke, arg2, pis[2], nameof(expression), nameof(arg2));

            return new InvocationExpression3(expression, method.ReturnType, arg0, arg1, arg2);
        }

Same methods

Expression::Invoke ( Expression expression ) : InvocationExpression
Expression::Invoke ( Expression expression, Expression arg0 ) : InvocationExpression
Expression::Invoke ( Expression expression, Expression arg0, Expression arg1 ) : InvocationExpression
Expression::Invoke ( Expression expression, Expression arg0, Expression arg1, Expression arg2, Expression arg3 ) : InvocationExpression
Expression::Invoke ( Expression expression, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4 ) : InvocationExpression
Expression::Invoke ( Expression expression, IEnumerable arguments ) : InvocationExpression

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Creates an expression that defines a logical AND function
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static Expression <Func <T, bool> > And <T>(this Expression <Func <T, bool> > left, Expression <Func <T, bool> > right)
        {
            var invokedExpr = XPR.Invoke(right, left.Parameters.Cast <XPR>());

            return(XPR.Lambda <Func <T, bool> >
                       (XPR.AndAlso(left.Body, invokedExpr), left.Parameters));
        }
All Usage Examples Of System.Linq.Expressions.Expression::Invoke
Expression