Freigeben über


Expression.Call Methode

Definition

Erstellt eine MethodCallExpression.

Überlädt

Name Beschreibung
Call(MethodInfo, Expression, Expression, Expression, Expression, Expression)

Erstellt einen MethodCallExpression , der einen Aufruf einer statischen Methode darstellt, die fünf Argumente akzeptiert.

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

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die drei Argumente akzeptiert.

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

Erstellt einen MethodCallExpression , der einen Aufruf einer static (Shared in Visual Basic) -Methode darstellt, indem die entsprechende Factorymethode aufgerufen wird.

Call(MethodInfo, Expression, Expression, Expression)

Erstellt einen MethodCallExpression , der einen Aufruf einer statischen Methode darstellt, die drei Argumente akzeptiert.

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

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, indem die entsprechende Factorymethode aufgerufen wird.

Call(Expression, MethodInfo, Expression, Expression)

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die zwei Argumente akzeptiert.

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

Erstellt einen MethodCallExpression , der einen Aufruf einer statischen Methode darstellt, die vier Argumente akzeptiert.

Call(Expression, MethodInfo, Expression[])

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die Argumente akzeptiert.

Call(Expression, MethodInfo, IEnumerable<Expression>)

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die Argumente akzeptiert.

Call(MethodInfo, Expression[])

Erstellt eine MethodCallExpression , die einen Aufruf einer static (Shared in Visual Basic) -Methode darstellt, die Argumente enthält.

Call(MethodInfo, Expression)

Erstellt eine MethodCallExpression , die einen Aufruf einer static (Shared in Visual Basic) -Methode darstellt, die ein Argument verwendet.

Call(MethodInfo, IEnumerable<Expression>)

Erstellt einen MethodCallExpression , der einen Aufruf einer statischen (Shared in Visual Basic)-Methode darstellt.

Call(Expression, MethodInfo)

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die keine Argumente akzeptiert.

Call(MethodInfo, Expression, Expression)

Erstellt einen MethodCallExpression Wert, der einen Aufruf einer statischen Methode darstellt, die zwei Argumente akzeptiert.

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

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer statischen Methode darstellt, die fünf Argumente akzeptiert.

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

Parameter

method
MethodInfo

A MethodInfo , um die Method Eigenschaft gleich festzulegen.

arg0
Expression

Dies Expression stellt das erste Argument dar.

arg1
Expression

Dies Expression stellt das zweite Argument dar.

arg2
Expression

Dies Expression stellt das dritte Argument dar.

arg3
Expression

Dies Expression stellt das vierte Argument dar.

arg4
Expression

Dies Expression stellt das fünfte Argument dar.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Ausnahmen

method ist NULL.

Gilt für:

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

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die drei Argumente akzeptiert.

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

Parameter

instance
Expression

Ein Expression Wert, der die Instanz für einen Instanzaufruf angibt. (übergeben Sie NULL für eine statische (Shared in Visual Basic)-Methode).

method
MethodInfo

Dies MethodInfo stellt die Zielmethode dar.

arg0
Expression

Dies Expression stellt das erste Argument dar.

arg1
Expression

Dies Expression stellt das zweite Argument dar.

arg2
Expression

Dies Expression stellt das dritte Argument dar.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Gilt für:

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

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer static (Shared in Visual Basic) -Methode darstellt, indem die entsprechende Factorymethode aufgerufen wird.

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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calling a generic method requires dynamic code generation. This can be suppressed if the method is not generic.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calling a generic method cannot be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. This can be suppressed if the method is not generic.")]
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calling a generic method cannot be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. This can be suppressed if the method is not generic.")]
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
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calling a generic method requires dynamic code generation. This can be suppressed if the method is not generic.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calling a generic method cannot be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. This can be suppressed if the method is not generic.")>]
static member Call : Type * string * Type[] * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.MethodCallExpression
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calling a generic method cannot be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. This can be suppressed if the method is not generic.")>]
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

Parameter

type
Type

Der Typ, der die angegebene static (Shared in Visual Basic)-Methode enthält.

methodName
String

Der Name der Methode.

typeArguments
Type[]

Ein Array von Type Objekten, die die Typparameter der generischen Methode angeben. Dieses Argument sollte null sein, wenn methodName eine nicht generische Methode angibt.

arguments
Expression[]

Ein Array von Expression Objekten, die die Argumente für die Methode darstellen.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call, the Method property set to the MethodInfo that represents the specified static (Shared in Visual Basic) method, and the Arguments property set to the specified arguments.

Attribute

Ausnahmen

type oder methodName ist null.

Keine Methode, deren Name lautetmethodName, deren Typparameter übereinstimmen typeArgumentsund deren Parametertypen in typearguments oder den Basistypen gefunden werden.

- oder -

Mehr als eine Methode, deren Name lautet methodName, deren Typparameter übereinstimmen typeArgumentsund deren Parametertypen in arguments den Basistypen gefunden type werden.

Hinweise

Die Type Eigenschaft des resultierenden MethodCallExpression Werts entspricht dem Rückgabetyp der Methode, die durch methodNameangegeben wird. Die Object Eigenschaft ist null.

Gilt für:

Call(MethodInfo, Expression, Expression, Expression)

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer statischen Methode darstellt, die drei Argumente akzeptiert.

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

Parameter

method
MethodInfo

A MethodInfo , um die Method Eigenschaft gleich festzulegen.

arg0
Expression

Dies Expression stellt das erste Argument dar.

arg1
Expression

Dies Expression stellt das zweite Argument dar.

arg2
Expression

Dies Expression stellt das dritte Argument dar.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Ausnahmen

method ist NULL.

Gilt für:

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

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, indem die entsprechende Factorymethode aufgerufen wird.

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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calling a generic method requires dynamic code generation. This can be suppressed if the method is not generic.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
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
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calling a generic method requires dynamic code generation. This can be suppressed if the method is not generic.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")>]
static member Call : System.Linq.Expressions.Expression * string * Type[] * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.MethodCallExpression
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")>]
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

Parameter

instance
Expression

Ein Expression Eigenschaftswert, dessen Type Eigenschaftswert nach einer bestimmten Methode gesucht wird.

methodName
String

Der Name der Methode.

typeArguments
Type[]

Ein Array von Type Objekten, die die Typparameter der generischen Methode angeben. Dieses Argument sollte null sein, wenn methodName eine nicht generische Methode angibt.

arguments
Expression[]

Ein Array von Expression Objekten, die die Argumente für die Methode darstellen.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call, the Object property equal to instance, Method set to the MethodInfo that represents the specified instance method, and Arguments set to the specified arguments.

Attribute

Ausnahmen

instance oder methodName ist null.

Keine Methode, deren Name lautet methodName, deren Typparameter übereinstimmen typeArgumentsund deren Parametertypen übereinstimmen arguments in instance. Geben Sie den Typ oder die zugehörigen Basistypen ein.

- oder -

Mehrere Methoden, deren Name lautet methodName, deren Typparameter übereinstimmen typeArgumentsund deren Parametertypen übereinstimmen arguments , finden Sie in instance. Geben Sie den Typ oder die zugehörigen Basistypen ein.

Hinweise

Die Type Eigenschaft des resultierenden MethodCallExpression Werts entspricht dem Rückgabetyp der Methode, die durch methodNameangegeben wird.

Gilt für:

Call(Expression, MethodInfo, Expression, Expression)

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die zwei Argumente akzeptiert.

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

Parameter

instance
Expression

Ein Expression Wert, der die Instanz für einen Instanzaufruf angibt. (übergeben Sie NULL für eine statische (Shared in Visual Basic)-Methode).

method
MethodInfo

Dies MethodInfo stellt die Zielmethode dar.

arg0
Expression

Dies Expression stellt das erste Argument dar.

arg1
Expression

Dies Expression stellt das zweite Argument dar.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Beispiele

Das folgende Codebeispiel zeigt, wie Sie einen Ausdruck erstellen, der eine Instanzmethode mit zwei Argumenten aufruft.

// 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

Gilt für:

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

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer statischen Methode darstellt, die vier Argumente akzeptiert.

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

Parameter

method
MethodInfo

A MethodInfo , um die Method Eigenschaft gleich festzulegen.

arg0
Expression

Dies Expression stellt das erste Argument dar.

arg1
Expression

Dies Expression stellt das zweite Argument dar.

arg2
Expression

Dies Expression stellt das dritte Argument dar.

arg3
Expression

Dies Expression stellt das vierte Argument dar.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Ausnahmen

method ist NULL.

Gilt für:

Call(Expression, MethodInfo, Expression[])

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die Argumente akzeptiert.

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

Parameter

instance
Expression

Ein Expression Wert, der die Instanz für einen Instanzmethodenaufruf angibt (übergeben null für eine static (Shared in Visual Basic)-Methode).

method
MethodInfo

A MethodInfo , um die Method Eigenschaft gleich festzulegen.

arguments
Expression[]

Ein Array von Expression Objekten, die zum Auffüllen der Arguments Auflistung verwendet werden sollen.

Gibt zurück

Ein MethodCallExpression Wert, der die NodeType Eigenschaft entsprichtCall, und Arguments die Eigenschaften, die ObjectMethodauf die angegebenen Werte festgelegt sind.

Ausnahmen

method ist null.

- oder -

instance ist null und method stellt eine Instanzmethode dar.

- oder -

arguments ist nicht null und ein oder mehrere seiner Elemente sind null.

instance. Der Typ kann dem deklarierenden Typ der durch die Methode dargestellten methodnicht zugewiesen werden.

- oder -

Die Anzahl der Elemente in arguments entspricht nicht der Anzahl der Parameter für die methode dargestellt durch method.

- oder -

Mindestens eines der Elemente von arguments ist dem entsprechenden Parameter für die durch die Methode dargestellte methodMethode nicht zuzuweisen.

Hinweise

Um einen Aufruf einer static ( in Visual Basic)-Methode darzustellen, übergeben null Sie den instance Parameter, wenn Sie diese Methode aufrufen, oder rufen Sie stattdessen aufCallShared.

Wenn method sie eine Instanzmethode darstellt, muss die Type Eigenschaft instance dem deklarierenden Typ der durch methoddargestellten Methode zugewiesen werden können.

Ist arguments dies nicht nullder Fall, muss sie dieselbe Anzahl von Elementen wie die Anzahl der Parameter für die durch methoddie Methode dargestellte . Jedes Element in arguments darf nicht sein null und muss dem entsprechenden Parameter von method, möglicherweise nach der Quotierung, zugewiesen werden können.

Hinweis

Ein Element wird nur zitiert, wenn der entsprechende Methodenparameter vom Typ Expressionist. Quoting bedeutet, dass das Element in einen Quote Knoten umbrochen wird. Der resultierende Knoten ist eine UnaryExpression Eigenschaft, deren Operand Eigenschaft das Element von arguments.

Die Arguments Eigenschaft des resultierenden MethodCallExpression Ist-Werts ist leer, wenn arguments dies der Wert ist null. Andernfalls enthält sie dieselben Elemente wie arguments, von denen einige zitiert werden können.

Die Type Eigenschaft des resultierenden MethodCallExpression Objekts entspricht dem Rückgabetyp der durch method.

Gilt für:

Call(Expression, MethodInfo, IEnumerable<Expression>)

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die Argumente akzeptiert.

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

Parameter

instance
Expression

Eine Expression , die die Object Eigenschaft gleich (pass null for a static (Shared in Visual Basic) -Methode festlegen soll.

method
MethodInfo

A MethodInfo , um die Method Eigenschaft gleich festzulegen.

arguments
IEnumerable<Expression>

Ein IEnumerable<T> Objekt, das Objekte enthält Expression , die zum Auffüllen der Arguments Auflistung verwendet werden sollen.

Gibt zurück

Ein MethodCallExpression Wert, der die NodeType Eigenschaft entsprichtCall, und Arguments die Eigenschaften, die ObjectMethodauf die angegebenen Werte festgelegt sind.

Ausnahmen

method ist null.

- oder -

instance ist null und method stellt eine Instanzmethode dar.

instance. Der Typ kann dem deklarierenden Typ der durch die Methode dargestellten methodnicht zugewiesen werden.

- oder -

Die Anzahl der Elemente in arguments entspricht nicht der Anzahl der Parameter für die methode dargestellt durch method.

- oder -

Mindestens eines der Elemente von arguments ist dem entsprechenden Parameter für die durch die Methode dargestellte methodMethode nicht zuzuweisen.

Hinweise

Um einen Aufruf einer static ( in Visual Basic)-Methode darzustellen, übergeben null Sie den instance Parameter, wenn Sie diese Methode aufrufen, oder rufen Sie stattdessen aufCallShared.

Wenn method sie eine Instanzmethode darstellt, muss die Type Eigenschaft instance dem deklarierenden Typ der durch methoddargestellten Methode zugewiesen werden können.

Ist arguments dies nicht nullder Fall, muss sie dieselbe Anzahl von Elementen wie die Anzahl der Parameter für die durch methoddie Methode dargestellte . Jedes Element in arguments darf nicht sein null und muss dem entsprechenden Parameter von method, möglicherweise nach der Quotierung, zugewiesen werden können.

Hinweis

Ein Element wird nur zitiert, wenn der entsprechende Methodenparameter vom Typ Expressionist. Quoting bedeutet, dass das Element in einen Quote Knoten umbrochen wird. Der resultierende Knoten ist eine UnaryExpression Eigenschaft, deren Operand Eigenschaft das Element von arguments.

Die Arguments Eigenschaft des resultierenden MethodCallExpression Ist-Werts ist leer, wenn arguments dies der Wert ist null. Andernfalls enthält sie dieselben Elemente wie arguments, von denen einige zitiert werden können.

Die Type Eigenschaft des resultierenden MethodCallExpression Objekts entspricht dem Rückgabetyp der durch method.

Gilt für:

Call(MethodInfo, Expression[])

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt eine MethodCallExpression , die einen Aufruf einer static (Shared in Visual Basic) -Methode darstellt, die Argumente enthält.

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

Parameter

method
MethodInfo

A MethodInfo that represents a static (Shared in Visual Basic) method to set the Method property equal to.

arguments
Expression[]

Ein Array von Expression Objekten, die zum Auffüllen der Arguments Auflistung verwendet werden sollen.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the MethodArguments properties set to the specified values.

Ausnahmen

method ist null.

Die Anzahl der Elemente in arguments entspricht nicht der Anzahl der Parameter für die methode dargestellt durch method.

- oder -

Mindestens eines der Elemente von arguments ist dem entsprechenden Parameter für die durch die Methode dargestellte methodMethode nicht zuzuweisen.

Hinweise

Ist arguments dies nicht nullder Fall, muss sie dieselbe Anzahl von Elementen wie die Anzahl der Parameter für die durch methoddie Methode dargestellte . Jedes Element in arguments darf nicht sein null und muss dem entsprechenden Parameter von method, möglicherweise nach der Quotierung, zugewiesen werden können.

Hinweis

Ein Element wird nur zitiert, wenn der entsprechende Methodenparameter vom Typ Expressionist. Quoting bedeutet, dass das Element in einen Quote Knoten umbrochen wird. Der resultierende Knoten ist eine UnaryExpression Eigenschaft, deren Operand Eigenschaft das Element von arguments.

Die Arguments Eigenschaft des resultierenden MethodCallExpression Ist-Werts ist leer, wenn arguments dies der Wert ist null. Andernfalls enthält sie dieselben Elemente wie arguments, von denen einige zitiert werden können.

Die Type Eigenschaft des resultierenden MethodCallExpression Objekts entspricht dem Rückgabetyp der durch method. Die Object Eigenschaft ist null.

Gilt für:

Call(MethodInfo, Expression)

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt eine MethodCallExpression , die einen Aufruf einer static (Shared in Visual Basic) -Methode darstellt, die ein Argument verwendet.

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

Parameter

method
MethodInfo

A MethodInfo , um die Method Eigenschaft gleich festzulegen.

arg0
Expression

Dies Expression stellt das erste Argument dar.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Ausnahmen

method ist NULL.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie Sie einen Ausdruck erstellen, der eine static (Shared in Visual Basic)-Methode aufruft, die ein Argument verwendet.

// 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

Gilt für:

Call(MethodInfo, IEnumerable<Expression>)

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer statischen (Shared in Visual Basic)-Methode darstellt.

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

Parameter

method
MethodInfo

Dies MethodInfo stellt die Zielmethode dar.

arguments
IEnumerable<Expression>

Eine Auflistung, die Expression die Aufrufargumente darstellt.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Gilt für:

Call(Expression, MethodInfo)

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression , der einen Aufruf einer Methode darstellt, die keine Argumente akzeptiert.

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

Parameter

instance
Expression

Ein Expression Wert, der die Instanz für einen Instanzmethodenaufruf angibt (übergeben null für eine static (Shared in Visual Basic)-Methode).

method
MethodInfo

A MethodInfo , um die Method Eigenschaft gleich festzulegen.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Ausnahmen

method ist null.

- oder -

instance ist null und method stellt eine Instanzmethode dar.

instance. Der Typ kann dem deklarierenden Typ der durch die Methode dargestellten methodnicht zugewiesen werden.

Beispiele

Das folgende Codebeispiel zeigt, wie Sie einen Ausdruck erstellen, der eine Methode ohne Argumente aufruft.

// 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

Hinweise

Um einen Aufruf einer static (Shared in Visual Basic)-Methode darzustellen, übergeben null Sie den instance Parameter, wenn Sie diese Methode aufrufen.

Wenn method sie eine Instanzmethode darstellt, muss die Type Eigenschaft instance dem deklarierenden Typ der durch methoddargestellten Methode zugewiesen werden können.

Die Arguments Eigenschaft der resultierenden MethodCallExpression ist leer. Die Type Eigenschaft ist gleich dem Rückgabetyp der durch method.

Gilt für:

Call(MethodInfo, Expression, Expression)

Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs
Quelle:
MethodCallExpression.cs

Erstellt einen MethodCallExpression Wert, der einen Aufruf einer statischen Methode darstellt, die zwei Argumente akzeptiert.

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

Parameter

method
MethodInfo

A MethodInfo , um die Method Eigenschaft gleich festzulegen.

arg0
Expression

Dies Expression stellt das erste Argument dar.

arg1
Expression

Dies Expression stellt das zweite Argument dar.

Gibt zurück

A MethodCallExpression that has the NodeType property equal to Call and the ObjectMethod properties set to the specified values.

Ausnahmen

method ist NULL.

Gilt für: