Expression.Invoke Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Tworzy element InvocationExpression.
Przeciążenia
| Invoke(Expression, Expression[]) |
Tworzy obiekt InvocationExpression , który stosuje wyrażenie delegata lub lambda do listy wyrażeń argumentów. |
| Invoke(Expression, IEnumerable<Expression>) |
Tworzy obiekt InvocationExpression , który stosuje wyrażenie delegata lub lambda do listy wyrażeń argumentów. |
Invoke(Expression, Expression[])
- Źródło:
- InvocationExpression.cs
- Źródło:
- InvocationExpression.cs
- Źródło:
- InvocationExpression.cs
Tworzy obiekt InvocationExpression , który stosuje wyrażenie delegata lub lambda do listy wyrażeń argumentów.
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
Parametry
- expression
- Expression
Element Expression reprezentujący wyrażenie delegata lub lambda do zastosowania.
- arguments
- Expression[]
Tablica Expression obiektów reprezentujących argumenty, do których jest stosowane wyrażenie delegata lub lambda.
Zwraca
Element InvocationExpression , który stosuje określone wyrażenie delegata lub lambda do podanych argumentów.
Wyjątki
expression to null.
expression. Typ nie reprezentuje typu delegata ani .Expression<TDelegate>
-lub-
Właściwość Type elementu elementu arguments nie jest przypisywana do typu odpowiadającego mu parametru delegata reprezentowanego przez expression.
arguments nie zawiera tej samej liczby elementów, co lista parametrów delegata reprezentowanego przez expression.
Przykłady
W poniższym przykładzie pokazano, jak użyć Invoke(Expression, Expression[]) metody w celu utworzenia obiektu InvocationExpression reprezentującego wywołanie wyrażenia lambda z określonymi argumentami.
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)
Uwagi
Właściwość Type wynikowego InvocationExpression reprezentuje zwracany typ delegata reprezentowanego przez expressionelement . Typu.
Właściwość Arguments wynikowej InvocationExpression jest pusta, jeśli arguments ma wartość null. W przeciwnym razie zawiera te same elementy, co arguments z wyjątkiem tego, że niektóre z tych Expression obiektów mogą być cytowane.
Uwaga
Element będzie cytowany tylko wtedy, gdy odpowiedni parametr delegata reprezentowanego przez expression 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.
Dotyczy
Invoke(Expression, IEnumerable<Expression>)
- Źródło:
- InvocationExpression.cs
- Źródło:
- InvocationExpression.cs
- Źródło:
- InvocationExpression.cs
Tworzy obiekt InvocationExpression , który stosuje wyrażenie delegata lub lambda do listy wyrażeń argumentów.
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
Parametry
- expression
- Expression
Element Expression reprezentujący wyrażenie delegata lub lambda, do którego ma zostać zastosowane.
- arguments
- IEnumerable<Expression>
Obiekt IEnumerable<T> zawierający Expression obiekty reprezentujące argumenty, do których jest stosowane wyrażenie delegata lub lambda.
Zwraca
Element InvocationExpression , który stosuje określone wyrażenie delegata lub lambda do podanych argumentów.
Wyjątki
expression to null.
expression. Typ nie reprezentuje typu delegata ani .Expression<TDelegate>
-lub-
Właściwość Type elementu elementu arguments nie jest przypisywana do typu odpowiadającego mu parametru delegata reprezentowanego przez expression.
arguments nie zawiera tej samej liczby elementów, co lista parametrów delegata reprezentowanego przez expression.
Przykłady
W poniższym przykładzie pokazano, jak użyć Invoke(Expression, Expression[]) metody w celu utworzenia obiektu InvocationExpression reprezentującego wywołanie wyrażenia lambda z określonymi argumentami.
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)
Uwagi
Właściwość Type wynikowego InvocationExpression reprezentuje zwracany typ delegata reprezentowanego przez expressionelement . Typu.
Właściwość Arguments wynikowej InvocationExpression jest pusta, jeśli arguments ma wartość null. W przeciwnym razie zawiera te same elementy, co arguments z wyjątkiem tego, że niektóre z tych Expression obiektów mogą być cytowane.
Uwaga
Element będzie cytowany tylko wtedy, gdy odpowiedni parametr delegata reprezentowanego przez expression 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.