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

Call() public static method

Creates a MethodCallExpression that represents a call to a static method that takes five arguments.
/// is null.
public static Call ( MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4 ) : MethodCallExpression
method System.Reflection.MethodInfo A to set the property equal to.
arg0 Expression The that represents the first argument.
arg1 Expression The that represents the second argument.
arg2 Expression The that represents the third argument.
arg3 Expression The that represents the fourth argument.
arg4 Expression The that represents the fifth argument.
return MethodCallExpression
        public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4)
        {
            ContractUtils.RequiresNotNull(method, nameof(method));
            ContractUtils.RequiresNotNull(arg0, nameof(arg0));
            ContractUtils.RequiresNotNull(arg1, nameof(arg1));
            ContractUtils.RequiresNotNull(arg2, nameof(arg2));
            ContractUtils.RequiresNotNull(arg3, nameof(arg3));
            ContractUtils.RequiresNotNull(arg4, nameof(arg4));

            ParameterInfo[] pis = ValidateMethodAndGetParameters(null, method);

            ValidateArgumentCount(method, ExpressionType.Call, 5, pis);

            arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, pis[0], nameof(method), nameof(arg0));
            arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, pis[1], nameof(method), nameof(arg1));
            arg2 = ValidateOneArgument(method, ExpressionType.Call, arg2, pis[2], nameof(method), nameof(arg2));
            arg3 = ValidateOneArgument(method, ExpressionType.Call, arg3, pis[3], nameof(method), nameof(arg3));
            arg4 = ValidateOneArgument(method, ExpressionType.Call, arg4, pis[4], nameof(method), nameof(arg4));

            return new MethodCallExpression5(method, arg0, arg1, arg2, arg3, arg4);
        }

Same methods

Expression::Call ( Expression instance, MethodInfo method ) : MethodCallExpression
Expression::Call ( Expression instance, MethodInfo method, Expression arg0 ) : MethodCallExpression
Expression::Call ( Expression instance, MethodInfo method, Expression arg0, Expression arg1 ) : MethodCallExpression
Expression::Call ( Expression instance, MethodInfo method, Expression arg0, Expression arg1, Expression arg2 ) : MethodCallExpression
Expression::Call ( Expression instance, MethodInfo method, IEnumerable arguments ) : MethodCallExpression
Expression::Call ( Expression instance, string methodName, Type typeArguments ) : MethodCallExpression
Expression::Call ( MethodInfo method ) : MethodCallExpression
Expression::Call ( MethodInfo method, Expression arg0 ) : MethodCallExpression
Expression::Call ( MethodInfo method, Expression arg0, Expression arg1 ) : MethodCallExpression
Expression::Call ( MethodInfo method, Expression arg0, Expression arg1, Expression arg2 ) : MethodCallExpression
Expression::Call ( MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3 ) : MethodCallExpression
Expression::Call ( MethodInfo method, IEnumerable arguments ) : MethodCallExpression
Expression::Call ( Type type, string methodName, Type typeArguments ) : MethodCallExpression

Usage Example

コード例 #1
0
        private static Func <int[], int[]> GenerateCopyExpression()
        {
            var ctor = typeof(int[]).GetConstructor(new[] { typeof(int) });
            var get  = typeof(int[]).GetMethod("Get", new[] { typeof(int) });
            var set  = typeof(int[]).GetMethod("Set", new[] { typeof(int), typeof(int) });

            var p1     = Exp.Parameter(typeof(int[]));
            var v1     = Exp.Variable(typeof(int[]));
            var v2     = Exp.Variable(typeof(int));
            var @break = Exp.Label();

            var block = Exp.Block(
                new[] { v1, v2 },
                Exp.Assign(v1, Exp.New(ctor, Exp.Property(p1, "Length"))),
                Exp.Assign(v2, Exp.Constant(0)),
                Exp.Loop(
                    Exp.IfThenElse(
                        Exp.LessThan(v2, Exp.Property(p1, "Length")),
                        Exp.Block(
                            Exp.Call(v1, set, v2, Exp.Call(p1, get, v2)),
                            Exp.AddAssign(v2, Exp.Constant(1))
                            ),
                        Exp.Break(@break)
                        ),
                    @break),
                v1
                );

            return(Exp.Lambda <Func <int[], int[]> >(block, new ParameterExpression[] { p1 }).Compile());
        }
All Usage Examples Of System.Linq.Expressions.Expression::Call
Expression