Expression.Invoke Methode

Definition

Erstellt ein InvocationExpression.

Überlädt

Invoke(Expression, Expression[])

Erstellt ein InvocationExpression, das einen Delegaten oder einen Lambdaausdruck auf eine Liste von Argumentausdrücken anwendet.

Invoke(Expression, IEnumerable<Expression>)

Erstellt ein InvocationExpression, das einen Delegaten oder einen Lambdaausdruck auf eine Liste von Argumentausdrücken anwendet.

Invoke(Expression, Expression[])

Quelle:
InvocationExpression.cs
Quelle:
InvocationExpression.cs
Quelle:
InvocationExpression.cs

Erstellt ein InvocationExpression, das einen Delegaten oder einen Lambdaausdruck auf eine Liste von Argumentausdrücken anwendet.

public:
 static System::Linq::Expressions::InvocationExpression ^ Invoke(System::Linq::Expressions::Expression ^ expression, ... cli::array <System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.InvocationExpression Invoke (System.Linq.Expressions.Expression expression, params System.Linq.Expressions.Expression[] arguments);
public static System.Linq.Expressions.InvocationExpression Invoke (System.Linq.Expressions.Expression expression, params System.Linq.Expressions.Expression[]? arguments);
static member Invoke : System.Linq.Expressions.Expression * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.InvocationExpression
Public Shared Function Invoke (expression As Expression, ParamArray arguments As Expression()) As InvocationExpression

Parameter

expression
Expression

Ein Expression, das den anzuwendenden Delegaten oder Lambda-Ausdruck darstellt.

arguments
Expression[]

Ein Array von Expression-Objekten, die die Argumente darstellen, auf die der Delegat oder der Lambdaausdruck angewendet wird.

Gibt zurück

Ein InvocationExpression, das den angegebenen Delegaten oder Lambdaausdruck auf die bereitgestellten Argumente anwendet.

Ausnahmen

expression ist null.

expression.Type stellt keinen Delegattyp und keine Expression<TDelegate> dar.

- oder -

Die Type-Eigenschaft eines Elements von arguments kann nicht dem Typ des entsprechenden Parameters des durch expression dargestellten Delegaten zugeordnet werden.

arguments enthält nicht dieselbe Anzahl an Elementen wie die Liste der Parameter für den durch expression dargestellten Delegaten.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie die Invoke(Expression, Expression[]) -Methode verwendet wird, um eine InvocationExpression zu erstellen, die den Aufruf eines Lambdaausdrucks mit angegebenen Argumenten darstellt.

System.Linq.Expressions.Expression<Func<int, int, bool>> largeSumTest =
    (num1, num2) => (num1 + num2) > 1000;

// Create an InvocationExpression that represents applying
// the arguments '539' and '281' to the lambda expression 'largeSumTest'.
System.Linq.Expressions.InvocationExpression invocationExpression =
    System.Linq.Expressions.Expression.Invoke(
        largeSumTest,
        System.Linq.Expressions.Expression.Constant(539),
        System.Linq.Expressions.Expression.Constant(281));

Console.WriteLine(invocationExpression.ToString());

// This code produces the following output:
//
// Invoke((num1, num2) => ((num1 + num2) > 1000),539,281)
Dim largeSumTest As System.Linq.Expressions.Expression(Of System.Func(Of Integer, Integer, Boolean)) = _
    Function(num1, num2) (num1 + num2) > 1000

' Create an InvocationExpression that represents applying
' the arguments '539' and '281' to the lambda expression 'largeSumTest'.
Dim invocationExpression As System.Linq.Expressions.InvocationExpression = _
    System.Linq.Expressions.Expression.Invoke( _
        largeSumTest, _
        System.Linq.Expressions.Expression.Constant(539), _
        System.Linq.Expressions.Expression.Constant(281))

Console.WriteLine(invocationExpression.ToString())

' This code produces the following output:
'
' Invoke((num1, num2) => ((num1 + num2) > 1000),539,281)

Hinweise

Die Type -Eigenschaft des resultierenden InvocationExpression stellt den Rückgabetyp des Delegaten dar, der durch expressiondargestellt wird. Typ.

Die Arguments -Eigenschaft des resultierenden InvocationExpression ist leer, wenn arguments ist null. Andernfalls enthält sie die gleichen Elemente wie arguments , mit der Ausnahme, dass einige dieser Expression Objekte in Anführungszeichen gesetzt werden können.

Hinweis

Ein Element wird nur in Anführungszeichen gesetzt, wenn der entsprechende Parameter des Durch dargestellten expression Delegaten vom Typ Expressionist. Anführungszeichen bedeutet, dass das Element in einen Quote Knoten umschlossen ist. Der resultierende Knoten ist ein UnaryExpression , dessen Operand -Eigenschaft das -Element von argumentsist.

Gilt für:

Invoke(Expression, IEnumerable<Expression>)

Quelle:
InvocationExpression.cs
Quelle:
InvocationExpression.cs
Quelle:
InvocationExpression.cs

Erstellt ein InvocationExpression, das einen Delegaten oder einen Lambdaausdruck auf eine Liste von Argumentausdrücken anwendet.

public:
 static System::Linq::Expressions::InvocationExpression ^ Invoke(System::Linq::Expressions::Expression ^ expression, System::Collections::Generic::IEnumerable<System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.InvocationExpression Invoke (System.Linq.Expressions.Expression expression, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> arguments);
public static System.Linq.Expressions.InvocationExpression Invoke (System.Linq.Expressions.Expression expression, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression>? arguments);
static member Invoke : System.Linq.Expressions.Expression * seq<System.Linq.Expressions.Expression> -> System.Linq.Expressions.InvocationExpression
Public Shared Function Invoke (expression As Expression, arguments As IEnumerable(Of Expression)) As InvocationExpression

Parameter

expression
Expression

Ein Expression, das den anzuwendenden Delegaten oder Lambdaausdruck darstellt.

arguments
IEnumerable<Expression>

Ein IEnumerable<T> mit den Expression-Objekten, die die Argumente darstellen, auf die der Delegat oder Lambdaausdruck angewendet wird.

Gibt zurück

Ein InvocationExpression, das den angegebenen Delegaten oder Lambdaausdruck auf die bereitgestellten Argumente anwendet.

Ausnahmen

expression ist null.

expression.Type stellt keinen Delegattyp und keine Expression<TDelegate> dar.

- oder -

Die Type-Eigenschaft eines Elements von arguments kann nicht dem Typ des entsprechenden Parameters des durch expression dargestellten Delegaten zugeordnet werden.

arguments enthält nicht dieselbe Anzahl an Elementen wie die Liste der Parameter für den durch expression dargestellten Delegaten.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie die Invoke(Expression, Expression[]) -Methode verwendet wird, um eine InvocationExpression zu erstellen, die den Aufruf eines Lambdaausdrucks mit angegebenen Argumenten darstellt.

System.Linq.Expressions.Expression<Func<int, int, bool>> largeSumTest =
    (num1, num2) => (num1 + num2) > 1000;

// Create an InvocationExpression that represents applying
// the arguments '539' and '281' to the lambda expression 'largeSumTest'.
System.Linq.Expressions.InvocationExpression invocationExpression =
    System.Linq.Expressions.Expression.Invoke(
        largeSumTest,
        System.Linq.Expressions.Expression.Constant(539),
        System.Linq.Expressions.Expression.Constant(281));

Console.WriteLine(invocationExpression.ToString());

// This code produces the following output:
//
// Invoke((num1, num2) => ((num1 + num2) > 1000),539,281)
Dim largeSumTest As System.Linq.Expressions.Expression(Of System.Func(Of Integer, Integer, Boolean)) = _
    Function(num1, num2) (num1 + num2) > 1000

' Create an InvocationExpression that represents applying
' the arguments '539' and '281' to the lambda expression 'largeSumTest'.
Dim invocationExpression As System.Linq.Expressions.InvocationExpression = _
    System.Linq.Expressions.Expression.Invoke( _
        largeSumTest, _
        System.Linq.Expressions.Expression.Constant(539), _
        System.Linq.Expressions.Expression.Constant(281))

Console.WriteLine(invocationExpression.ToString())

' This code produces the following output:
'
' Invoke((num1, num2) => ((num1 + num2) > 1000),539,281)

Hinweise

Die Type -Eigenschaft des resultierenden InvocationExpression stellt den Rückgabetyp des Delegaten dar, der durch expressiondargestellt wird. Typ.

Die Arguments -Eigenschaft des resultierenden InvocationExpression ist leer, wenn arguments ist null. Andernfalls enthält sie die gleichen Elemente wie arguments , mit der Ausnahme, dass einige dieser Expression Objekte in Anführungszeichen gesetzt werden können.

Hinweis

Ein Element wird nur in Anführungszeichen gesetzt, wenn der entsprechende Parameter des Durch dargestellten expression Delegaten vom Typ Expressionist. Anführungszeichen bedeutet, dass das Element in einen Quote Knoten umschlossen ist. Der resultierende Knoten ist ein UnaryExpression , dessen Operand -Eigenschaft das -Element von argumentsist.

Gilt für: