Expression.Call Metoda

Definicja

Tworzy element MethodCallExpression.

Przeciążenia

Call(MethodInfo, Expression, Expression, Expression, Expression, Expression)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej, która przyjmuje pięć argumentów.

Call(Expression, MethodInfo, Expression, Expression, Expression)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która przyjmuje trzy argumenty.

Call(Type, String, Type[], Expression[])

Tworzy obiekt MethodCallExpression , który reprezentuje wywołanie static metody (Shared w języku Visual Basic), wywołując odpowiednią metodę fabryki.

Call(MethodInfo, Expression, Expression, Expression)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej, która przyjmuje trzy argumenty.

Call(Expression, String, Type[], Expression[])

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody przez wywołanie odpowiedniej metody fabryki.

Call(Expression, MethodInfo, Expression, Expression)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która przyjmuje dwa argumenty.

Call(MethodInfo, Expression, Expression, Expression, Expression)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej, która przyjmuje cztery argumenty.

Call(Expression, MethodInfo, Expression[])

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która przyjmuje argumenty.

Call(Expression, MethodInfo, IEnumerable<Expression>)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która przyjmuje argumenty.

Call(MethodInfo, Expression[])

Tworzy obiekt MethodCallExpression , który reprezentuje wywołanie static metody (Shared w Visual Basic), która ma argumenty.

Call(MethodInfo, Expression)

Tworzy obiekt MethodCallExpression , który reprezentuje wywołanie static metody (Shared w Visual Basic), która przyjmuje jeden argument.

Call(MethodInfo, IEnumerable<Expression>)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej (udostępnionej w visual basic).

Call(Expression, MethodInfo)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która nie przyjmuje żadnych argumentów.

Call(MethodInfo, Expression, Expression)

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej, która przyjmuje dwa argumenty.

Call(MethodInfo, Expression, Expression, Expression, Expression, Expression)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej, która przyjmuje pięć argumentów.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Reflection::MethodInfo ^ method, System::Linq::Expressions::Expression ^ arg0, System::Linq::Expressions::Expression ^ arg1, System::Linq::Expressions::Expression ^ arg2, System::Linq::Expressions::Expression ^ arg3, System::Linq::Expressions::Expression ^ arg4);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0, System.Linq.Expressions.Expression arg1, System.Linq.Expressions.Expression arg2, System.Linq.Expressions.Expression arg3, System.Linq.Expressions.Expression arg4);
static member Call : System.Reflection.MethodInfo * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (method As MethodInfo, arg0 As Expression, arg1 As Expression, arg2 As Expression, arg3 As Expression, arg4 As Expression) As MethodCallExpression

Parametry

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

arg0
Expression

Wartość Expression reprezentująca pierwszy argument.

arg1
Expression

Wartość Expression reprezentująca drugi argument.

arg2
Expression

Wartość Expression reprezentująca trzeci argument.

arg3
Expression

Wartość Expression reprezentująca czwarty argument.

arg4
Expression

Wartość Expression reprezentująca piąty argument.

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Wyjątki

method ma wartość null.

Dotyczy

Call(Expression, MethodInfo, Expression, Expression, Expression)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która przyjmuje trzy argumenty.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Linq::Expressions::Expression ^ instance, System::Reflection::MethodInfo ^ method, System::Linq::Expressions::Expression ^ arg0, System::Linq::Expressions::Expression ^ arg1, System::Linq::Expressions::Expression ^ arg2);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0, System.Linq.Expressions.Expression arg1, System.Linq.Expressions.Expression arg2);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression? instance, System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0, System.Linq.Expressions.Expression arg1, System.Linq.Expressions.Expression arg2);
static member Call : System.Linq.Expressions.Expression * System.Reflection.MethodInfo * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (instance As Expression, method As MethodInfo, arg0 As Expression, arg1 As Expression, arg2 As Expression) As MethodCallExpression

Parametry

instance
Expression

Element Expression określający wystąpienie wywołania wystąpienia. (przekaż wartość null dla metody statycznej (udostępnionej w Visual Basic).

method
MethodInfo

Element MethodInfo reprezentujący metodę docelową.

arg0
Expression

Wartość Expression reprezentująca pierwszy argument.

arg1
Expression

Wartość Expression reprezentująca drugi argument.

arg2
Expression

Wartość Expression reprezentująca trzeci argument.

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Dotyczy

Call(Type, String, Type[], Expression[])

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression , który reprezentuje wywołanie static metody (Shared w języku Visual Basic), wywołując odpowiednią metodę fabryki.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(Type ^ type, System::String ^ methodName, cli::array <Type ^> ^ typeArguments, ... cli::array <System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.MethodCallExpression Call (Type type, string methodName, Type[] typeArguments, params System.Linq.Expressions.Expression[] arguments);
public static System.Linq.Expressions.MethodCallExpression Call (Type type, string methodName, Type[]? typeArguments, params System.Linq.Expressions.Expression[]? arguments);
static member Call : Type * string * Type[] * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (type As Type, methodName As String, typeArguments As Type(), ParamArray arguments As Expression()) As MethodCallExpression

Parametry

type
Type

Typ, który zawiera określoną static metodę (Shared w Visual Basic).

methodName
String

Nazwa metody.

typeArguments
Type[]

Tablica Type obiektów określających parametry typu metody ogólnej. Ten argument powinien mieć wartość null, gdy methodName określa metodę niegeneryjną.

arguments
Expression[]

Tablica Expression obiektów reprezentujących argumenty metody .

Zwraca

Właściwość MethodCallExpression , która ma NodeType właściwość równą Call, Method właściwość ustawiona na MethodInfo wartość , która reprezentuje określoną static metodę (Shared w Visual Basic) i Arguments właściwość ustawioną na określone argumenty.

Wyjątki

type lub methodName ma wartość null.

Brak metody, której nazwa to methodName, której parametry typu są zgodne typeArgumentsz parametrami , i których typy parametrów są zgodne arguments w type typach podstawowych lub których typy parametrów.

-lub-

Więcej niż jedna metoda, której nazwa to methodName, której parametry typu są zgodne typeArguments, i których typy parametrów są zgodne arguments w type typach podstawowych lub ich typy podstawowe.

Uwagi

Właściwość Type wynikowej MethodCallExpression jest równa zwracanemu typowi metody oznaczonej przez methodName. Właściwość Object to null.

Dotyczy

Call(MethodInfo, Expression, Expression, Expression)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej, która przyjmuje trzy argumenty.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Reflection::MethodInfo ^ method, System::Linq::Expressions::Expression ^ arg0, System::Linq::Expressions::Expression ^ arg1, System::Linq::Expressions::Expression ^ arg2);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0, System.Linq.Expressions.Expression arg1, System.Linq.Expressions.Expression arg2);
static member Call : System.Reflection.MethodInfo * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (method As MethodInfo, arg0 As Expression, arg1 As Expression, arg2 As Expression) As MethodCallExpression

Parametry

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

arg0
Expression

Wartość Expression reprezentująca pierwszy argument.

arg1
Expression

Wartość Expression reprezentująca drugi argument.

arg2
Expression

Wartość Expression reprezentująca trzeci argument.

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Wyjątki

method ma wartość null.

Dotyczy

Call(Expression, String, Type[], Expression[])

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody przez wywołanie odpowiedniej metody fabryki.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Linq::Expressions::Expression ^ instance, System::String ^ methodName, cli::array <Type ^> ^ typeArguments, ... cli::array <System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression instance, string methodName, Type[] typeArguments, params System.Linq.Expressions.Expression[] arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression instance, string methodName, Type[]? typeArguments, params System.Linq.Expressions.Expression[]? arguments);
static member Call : System.Linq.Expressions.Expression * string * Type[] * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (instance As Expression, methodName As String, typeArguments As Type(), ParamArray arguments As Expression()) As MethodCallExpression

Parametry

instance
Expression

Obiekt Expression , którego Type wartość właściwości zostanie wyszukana w określonej metodzie.

methodName
String

Nazwa metody.

typeArguments
Type[]

Tablica Type obiektów określających parametry typu metody ogólnej. Ten argument powinien mieć wartość null, gdy methodName określa metodę niegeneryjną.

arguments
Expression[]

Tablica Expression obiektów, która reprezentuje argumenty metody .

Zwraca

ObiektMethodCallExpression, który ma właściwość równą NodeType , Object właściwość równa Callinstance, Method ustawioną na MethodInfo wartość , która reprezentuje określoną metodę wystąpienia i Arguments ustawioną na określone argumenty.

Wyjątki

instance lub methodName ma wartość null.

Brak metody, której nazwa to methodName, której parametry typu są zgodne typeArgumentsz parametrami , i których typy parametrów są zgodne arguments w pliku instance. Typ lub jego typy podstawowe.

-lub-

Więcej niż jedna metoda, której nazwa to methodName, której parametry typu są zgodne typeArgumentsz parametrami , i których typy parametrów są zgodne arguments w pliku instance. Typ lub jego typy podstawowe.

Uwagi

Właściwość Type wynikowej MethodCallExpression jest równa zwracanemu typowi metody oznaczonej przez methodName.

Dotyczy

Call(Expression, MethodInfo, Expression, Expression)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która przyjmuje dwa argumenty.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Linq::Expressions::Expression ^ instance, System::Reflection::MethodInfo ^ method, System::Linq::Expressions::Expression ^ arg0, System::Linq::Expressions::Expression ^ arg1);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0, System.Linq.Expressions.Expression arg1);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression? instance, System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0, System.Linq.Expressions.Expression arg1);
static member Call : System.Linq.Expressions.Expression * System.Reflection.MethodInfo * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (instance As Expression, method As MethodInfo, arg0 As Expression, arg1 As Expression) As MethodCallExpression

Parametry

instance
Expression

Element Expression określający wystąpienie wywołania wystąpienia. (przekaż wartość null dla metody statycznej (udostępnionej w Visual Basic).

method
MethodInfo

Element MethodInfo reprezentujący metodę docelową.

arg0
Expression

Wartość Expression reprezentująca pierwszy argument.

arg1
Expression

Wartość Expression reprezentująca drugi argument.

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Przykłady

W poniższym przykładzie kodu pokazano, jak utworzyć wyrażenie, które wywołuje metodę wystąpienia, która ma dwa argumenty.

// Add the following directive to your file:
// using System.Linq.Expressions;
public class SampleClass
{
    public int AddIntegers(int arg1, int arg2)
    {
        return arg1 + arg2;
    }
}

static public void TestCall()
{
    // This expression represents a call to an instance method that has two arguments.
    // The first argument is an expression that creates a new object of the specified type.
    Expression callExpr = Expression.Call(
        Expression.New(typeof(SampleClass)),
        typeof(SampleClass).GetMethod("AddIntegers", new Type[] { typeof(int), typeof(int) }),
        Expression.Constant(1),
        Expression.Constant(2)
        );

    // Print out the expression.
    Console.WriteLine(callExpr.ToString());

    // The following statement first creates an expression tree,
    // then compiles it, and then executes it.
    Console.WriteLine(Expression.Lambda<Func<int>>(callExpr).Compile()());

    // This code example produces the following output:
    //
    // new SampleClass().AddIntegers(1, 2)
    // 3
}
' Add the following directive to your file:
' Imports System.Linq.Expressions  

Public Class SampleClass
    Public Function AddIntegers(ByVal arg1 As Integer, ByVal arg2 As Integer) As Integer
        Return (arg1 + arg2)
    End Function
End Class
Public Shared Sub TestCall()
    ' This expression represents a call to an instance method that has two arguments.
    ' The first argument is an expression that creates a new object of the specified type.
    Dim callExpr As Expression = Expression.Call(
        Expression.[New](GetType(SampleClass)),
        GetType(SampleClass).GetMethod("AddIntegers", New Type() {GetType(Integer), GetType(Integer)}),
        Expression.Constant(1),
        Expression.Constant(2)
      )

    ' Print the expression.
    Console.WriteLine(callExpr.ToString())

    ' The following statement first creates an expression tree,
    ' then compiles it, and then executes it.
    Console.WriteLine(Expression.Lambda(Of Func(Of Integer))(callExpr).Compile()())
End Sub

' This code example produces the following output:
'
' new SampleClass().AddIntegers(1, 2)
' 3

Dotyczy

Call(MethodInfo, Expression, Expression, Expression, Expression)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej, która przyjmuje cztery argumenty.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Reflection::MethodInfo ^ method, System::Linq::Expressions::Expression ^ arg0, System::Linq::Expressions::Expression ^ arg1, System::Linq::Expressions::Expression ^ arg2, System::Linq::Expressions::Expression ^ arg3);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0, System.Linq.Expressions.Expression arg1, System.Linq.Expressions.Expression arg2, System.Linq.Expressions.Expression arg3);
static member Call : System.Reflection.MethodInfo * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (method As MethodInfo, arg0 As Expression, arg1 As Expression, arg2 As Expression, arg3 As Expression) As MethodCallExpression

Parametry

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

arg0
Expression

Wartość Expression reprezentująca pierwszy argument.

arg1
Expression

Wartość Expression reprezentująca drugi argument.

arg2
Expression

Wartość Expression reprezentująca trzeci argument.

arg3
Expression

Wartość Expression reprezentująca czwarty argument.

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Wyjątki

method ma wartość null.

Dotyczy

Call(Expression, MethodInfo, Expression[])

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która przyjmuje argumenty.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Linq::Expressions::Expression ^ instance, System::Reflection::MethodInfo ^ method, ... cli::array <System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, params System.Linq.Expressions.Expression[] arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression? instance, System.Reflection.MethodInfo method, params System.Linq.Expressions.Expression[]? arguments);
static member Call : System.Linq.Expressions.Expression * System.Reflection.MethodInfo * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (instance As Expression, method As MethodInfo, ParamArray arguments As Expression()) As MethodCallExpression

Parametry

instance
Expression

Element Expression określający wystąpienie wywołania metody wystąpienia (przekazać null dla static metody (Shared w Visual Basic).

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

arguments
Expression[]

Tablica Expression obiektów do użycia w celu wypełnienia kolekcji Arguments .

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object, Methodi właściwości Arguments ustawione na określone wartości.

Wyjątki

method to null.

-lub-

instancemethod element i null reprezentuje metodę wystąpienia.

-lub-

arguments nie null jest i co najmniej jeden z jego elementów jest null.

instance. Typ nie jest przypisywany do deklarowanego typu metody reprezentowanej przez method.

-lub-

Liczba elementów w arguments elemecie nie jest równa liczbie parametrów metody reprezentowanej przez methodmetodę .

-lub-

Co najmniej jeden element elementu arguments nie można przypisać do odpowiedniego parametru dla metody reprezentowanej przez method.

Uwagi

Aby reprezentować wywołanie metody (Shared w Visual Basic), należy przekazać nullstatic parametr instance podczas wywoływania tej metody lub wywołać Call metodę .

Jeśli method reprezentuje metodę wystąpienia, Type właściwość instance musi być przypisywana do deklarowanego typu metody reprezentowanej przez method.

Jeśli arguments nie nulljest , musi mieć taką samą liczbę elementów, jak liczba parametrów dla metody reprezentowanej przez method. Każdy element w arguments pliku nie może być null i musi być możliwy do przypisania do odpowiedniego parametru method, prawdopodobnie po cudzysłów.

Uwaga

Element będzie cytowany tylko wtedy, gdy odpowiedni parametr metody jest typu Expression. Cudzysłów oznacza, że element jest owinięty w węźle Quote . Wynikowy UnaryExpression węzeł jest, którego Operand właściwość jest elementem arguments.

Właściwość Arguments wynikowej MethodCallExpression jest pusta, jeśli arguments ma wartość null. W przeciwnym razie zawiera te same elementy co arguments, z których niektóre mogą być cytowane.

Właściwość Type wynikowej MethodCallExpression jest równa typowi zwracanej metody reprezentowanej przez methodmetodę .

Dotyczy

Call(Expression, MethodInfo, IEnumerable<Expression>)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która przyjmuje argumenty.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Linq::Expressions::Expression ^ instance, System::Reflection::MethodInfo ^ method, System::Collections::Generic::IEnumerable<System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression? instance, System.Reflection.MethodInfo method, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression>? arguments);
static member Call : System.Linq.Expressions.Expression * System.Reflection.MethodInfo * seq<System.Linq.Expressions.Expression> -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (instance As Expression, method As MethodInfo, arguments As IEnumerable(Of Expression)) As MethodCallExpression

Parametry

instance
Expression

Element Expression , aby ustawić właściwość równą Objectstatic (przekazać null dla metody (Shared w Visual Basic).

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

arguments
IEnumerable<Expression>

Obiekt IEnumerable<T> zawierający Expression obiekty używane do wypełniania kolekcji Arguments .

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object, Methodi właściwości Arguments ustawione na określone wartości.

Wyjątki

method to null.

-lub-

instancemethod element i null reprezentuje metodę wystąpienia.

instance. Typ nie jest przypisywany do deklarowanego typu metody reprezentowanej przez method.

-lub-

Liczba elementów w arguments elemecie nie jest równa liczbie parametrów metody reprezentowanej przez methodmetodę .

-lub-

Co najmniej jeden element elementu arguments nie można przypisać do odpowiedniego parametru dla metody reprezentowanej przez method.

Uwagi

Aby reprezentować wywołanie metody (Shared w Visual Basic), należy przekazać nullstatic parametr instance podczas wywoływania tej metody lub wywołać Call metodę .

Jeśli method reprezentuje metodę wystąpienia, Type właściwość instance musi być przypisywana do deklarowanego typu metody reprezentowanej przez method.

Jeśli arguments nie nulljest , musi mieć taką samą liczbę elementów, jak liczba parametrów dla metody reprezentowanej przez method. Każdy element w arguments pliku nie może być null i musi być możliwy do przypisania do odpowiedniego parametru method, prawdopodobnie po cudzysłów.

Uwaga

Element będzie cytowany tylko wtedy, gdy odpowiedni parametr metody jest typu Expression. Cudzysłów oznacza, że element jest owinięty w węźle Quote . Wynikowy UnaryExpression węzeł jest, którego Operand właściwość jest elementem arguments.

Właściwość Arguments wynikowej MethodCallExpression jest pusta, jeśli arguments ma wartość null. W przeciwnym razie zawiera te same elementy co arguments, z których niektóre mogą być cytowane.

Właściwość Type wynikowej MethodCallExpression jest równa typowi zwracanej metody reprezentowanej przez methodmetodę .

Dotyczy

Call(MethodInfo, Expression[])

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression , który reprezentuje wywołanie static metody (Shared w Visual Basic), która ma argumenty.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Reflection::MethodInfo ^ method, ... cli::array <System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, params System.Linq.Expressions.Expression[] arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, params System.Linq.Expressions.Expression[]? arguments);
static member Call : System.Reflection.MethodInfo * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (method As MethodInfo, ParamArray arguments As Expression()) As MethodCallExpression

Parametry

method
MethodInfo

Obiekt MethodInfo reprezentujący metodę static (Shared w Języku Visual Basic) w celu ustawienia właściwości równej Method .

arguments
Expression[]

Tablica Expression obiektów do użycia w celu wypełnienia kolekcji Arguments .

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Method właściwości i Arguments ustawione na określone wartości.

Wyjątki

method to null.

Liczba elementów w arguments elemecie nie jest równa liczbie parametrów metody reprezentowanej przez methodmetodę .

-lub-

Co najmniej jeden element elementu arguments nie można przypisać do odpowiedniego parametru dla metody reprezentowanej przez method.

Uwagi

Jeśli arguments nie nulljest , musi mieć taką samą liczbę elementów, jak liczba parametrów dla metody reprezentowanej przez method. Każdy element w arguments pliku nie może być null i musi być możliwy do przypisania do odpowiedniego parametru method, prawdopodobnie po cudzysłów.

Uwaga

Element będzie cytowany tylko wtedy, gdy odpowiedni parametr metody jest typu Expression. Cudzysłów oznacza, że element jest owinięty w węźle Quote . Wynikowy UnaryExpression węzeł jest, którego Operand właściwość jest elementem arguments.

Właściwość Arguments wynikowej MethodCallExpression jest pusta, jeśli arguments ma wartość null. W przeciwnym razie zawiera te same elementy co arguments, z których niektóre mogą być cytowane.

Właściwość Type wynikowej MethodCallExpression jest równa typowi zwracanej metody reprezentowanej przez methodmetodę . Właściwość Object to null.

Dotyczy

Call(MethodInfo, Expression)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression , który reprezentuje wywołanie static metody (Shared w Visual Basic), która przyjmuje jeden argument.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Reflection::MethodInfo ^ method, System::Linq::Expressions::Expression ^ arg0);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0);
static member Call : System.Reflection.MethodInfo * System.Linq.Expressions.Expression -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (method As MethodInfo, arg0 As Expression) As MethodCallExpression

Parametry

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

arg0
Expression

Wartość Expression reprezentująca pierwszy argument.

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Wyjątki

method ma wartość null.

Przykłady

W poniższym przykładzie pokazano, jak utworzyć wyrażenie, które wywołuje metodę static (Shared w języku Visual Basic), która przyjmuje jeden argument.

// Add the following directive to your file:
// using System.Linq.Expressions;

public class SampleClass
{
    public static int Increment(int arg1)
    {
        return arg1 + 1;
    }
}

static public void TestCall()
{

    //This expression represents a call to an instance method with one argument.
    Expression callExpr = Expression.Call(
                            typeof(SampleClass).GetMethod("Increment"),
                            Expression.Constant(2)
                        );

    // Print out the expression.
    Console.WriteLine(callExpr.ToString());

    // The following statement first creates an expression tree,
    // then compiles it, and then executes it.
    Console.WriteLine(Expression.Lambda<Func<int>>(callExpr).Compile()());

    // This code example produces the following output:
    //
    // Increment(2)
    // 3
}
' Add the following directive to your file:
' Imports System.Linq.Expressions  

Public Class SampleClass
    Shared Function Increment(ByVal arg1 As Integer) As Integer
        Return arg1 + 1
    End Function
End Class
Shared Sub TestCall()
    'This expression represents a call to an instance method with one argument.
    Dim callExpr As Expression = Expression.Call(
        GetType(SampleClass).GetMethod("Increment"),
        Expression.Constant(2))

    ' Print the expression.
    Console.WriteLine(callExpr.ToString())

    ' The following statement first creates an expression tree,
    ' then compiles it, and then executes it.
    Console.WriteLine(Expression.Lambda(Of Func(Of Integer))(callExpr).Compile()())
End Sub

' This code example produces the following output:
'
' Increment(2)
' 3

Dotyczy

Call(MethodInfo, IEnumerable<Expression>)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej (udostępnionej w visual basic).

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Reflection::MethodInfo ^ method, System::Collections::Generic::IEnumerable<System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> arguments);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression>? arguments);
static member Call : System.Reflection.MethodInfo * seq<System.Linq.Expressions.Expression> -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (method As MethodInfo, arguments As IEnumerable(Of Expression)) As MethodCallExpression

Parametry

method
MethodInfo

Element MethodInfo reprezentujący metodę docelową.

arguments
IEnumerable<Expression>

Kolekcja reprezentująca Expression argumenty wywołań.

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Dotyczy

Call(Expression, MethodInfo)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody, która nie przyjmuje żadnych argumentów.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Linq::Expressions::Expression ^ instance, System::Reflection::MethodInfo ^ method);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method);
public static System.Linq.Expressions.MethodCallExpression Call (System.Linq.Expressions.Expression? instance, System.Reflection.MethodInfo method);
static member Call : System.Linq.Expressions.Expression * System.Reflection.MethodInfo -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (instance As Expression, method As MethodInfo) As MethodCallExpression

Parametry

instance
Expression

Element Expression określający wystąpienie wywołania metody wystąpienia (przekazać null dla static metody (Shared w Visual Basic).

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Wyjątki

method to null.

-lub-

instancemethod element i null reprezentuje metodę wystąpienia.

instance. Typ nie jest przypisywany do deklarowanego typu metody reprezentowanej przez method.

Przykłady

Poniższy przykład kodu pokazuje, jak utworzyć wyrażenie, które wywołuje metodę bez argumentów.

// Add the following directive to your file:
// using System.Linq.Expressions;

// This expression represents a call to an instance method without arguments.
Expression callExpr = Expression.Call(
    Expression.Constant("sample string"), typeof(String).GetMethod("ToUpper", new Type[] { }));

// Print out the expression.
Console.WriteLine(callExpr.ToString());

// The following statement first creates an expression tree,
// then compiles it, and then executes it.
Console.WriteLine(Expression.Lambda<Func<String>>(callExpr).Compile()());

// This code example produces the following output:
//
// "sample string".ToUpper
// SAMPLE STRING
' Add the following directive to your file:
' Imports System.Linq.Expressions   

' This expression represents a call to an instance method without arguments.
Dim callExpr As Expression = Expression.Call(
    Expression.Constant("sample string"), GetType(String).GetMethod("ToUpper", New Type() {}))

' Print the expression.
Console.WriteLine(callExpr.ToString())

' The following statement first creates an expression tree,
' then compiles it, and then executes it.  
Console.WriteLine(Expression.Lambda(Of Func(Of String))(callExpr).Compile()())

' This code example produces the following output:
'
' "sample string".ToUpper
' SAMPLE STRING

Uwagi

Aby reprezentować wywołanie metody (Shared w Visual Basic), należy przekazać staticnull parametr podczas instance wywoływania tej metody.

Jeśli method reprezentuje metodę wystąpienia, Type właściwość instance musi być przypisywana do deklarowanego typu metody reprezentowanej przez method.

Właściwość Arguments wynikowej MethodCallExpression jest pusta. Właściwość Type jest równa zwracanemu typowi metody reprezentowanej przez method.

Dotyczy

Call(MethodInfo, Expression, Expression)

Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs
Źródło:
MethodCallExpression.cs

Tworzy obiekt MethodCallExpression reprezentujący wywołanie metody statycznej, która przyjmuje dwa argumenty.

public:
 static System::Linq::Expressions::MethodCallExpression ^ Call(System::Reflection::MethodInfo ^ method, System::Linq::Expressions::Expression ^ arg0, System::Linq::Expressions::Expression ^ arg1);
public static System.Linq.Expressions.MethodCallExpression Call (System.Reflection.MethodInfo method, System.Linq.Expressions.Expression arg0, System.Linq.Expressions.Expression arg1);
static member Call : System.Reflection.MethodInfo * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression -> System.Linq.Expressions.MethodCallExpression
Public Shared Function Call (method As MethodInfo, arg0 As Expression, arg1 As Expression) As MethodCallExpression

Parametry

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

arg0
Expression

Wartość Expression reprezentująca pierwszy argument.

arg1
Expression

Wartość Expression reprezentująca drugi argument.

Zwraca

Właściwość MethodCallExpression , która ma właściwość równą CallNodeType i Object właściwości i Method ustawione na określone wartości.

Wyjątki

method ma wartość null.

Dotyczy