InvocationExpression 類別

定義

代表將委派或 Lambda 運算式套用至引數運算式清單的運算式。Represents an expression that applies a delegate or lambda expression to a list of argument expressions.

public ref class InvocationExpression sealed : System::Linq::Expressions::Expression, System::Linq::Expressions::IArgumentProvider
public ref class InvocationExpression sealed : System::Linq::Expressions::Expression
public sealed class InvocationExpression : System.Linq.Expressions.Expression, System.Linq.Expressions.IArgumentProvider
public sealed class InvocationExpression : System.Linq.Expressions.Expression
type InvocationExpression = class
    inherit Expression
    interface IArgumentProvider
type InvocationExpression = class
    inherit Expression
Public NotInheritable Class InvocationExpression
Inherits Expression
Implements IArgumentProvider
Public NotInheritable Class InvocationExpression
Inherits Expression
繼承
InvocationExpression
實作

範例

下列範例 InvocationExpression 會建立,表示使用指定的引數叫用 lambda 運算式。The following example creates an InvocationExpression that represents invoking a lambda expression with specified arguments.

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)

備註

使用 Invoke factory 方法來建立 InvocationExpressionUse the Invoke factory methods to create an InvocationExpression.

NodeType InvocationExpressionInvokeThe NodeType of an InvocationExpression is Invoke.

屬性

Arguments

取得要套用委派或 Lambda 運算式的引數。Gets the arguments that the delegate or lambda expression is applied to.

CanReduce

表示節點可精簡為更簡單的節點。Indicates that the node can be reduced to a simpler node. 如果傳回 true,則可呼叫 Reduce() 以產生精簡的形式。If this returns true, Reduce() can be called to produce the reduced form.

(繼承來源 Expression)
Expression

取得要套用的委派或 Lambda 運算式。Gets the delegate or lambda expression to be applied.

NodeType

傳回此運算式的節點類型。Returns the node type of this expression. 覆寫此方法時,擴充節點應傳回 ExtensionExtension nodes should return Extension when overriding this method.

NodeType

取得這個 Expression 的節點類型。Gets the node type of this Expression.

(繼承來源 Expression)
Type

取得此 Expression 代表之運算式的靜態類型。Gets the static type of the expression that this Expression represents.

Type

取得此 Expression 代表之運算式的靜態類型。Gets the static type of the expression that this Expression represents.

(繼承來源 Expression)

方法

Accept(ExpressionVisitor)

分派給這個節點類型的特定造訪方法。Dispatches to the specific visit method for this node type. 例如,MethodCallExpression 會呼叫 VisitMethodCall(MethodCallExpression)For example, MethodCallExpression calls the VisitMethodCall(MethodCallExpression).

(繼承來源 Expression)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Reduce()

將這個節點精簡為更簡單的運算式。Reduces this node to a simpler expression. 如果 CanReduce 傳回 true,則應該傳回有效的運算式。If CanReduce returns true, this should return a valid expression. 這個方法可以傳回其他本身必須精簡的節點。This method can return another node which itself must be reduced.

(繼承來源 Expression)
ReduceAndCheck()

將這個節點精簡為更簡單的運算式。Reduces this node to a simpler expression. 如果 CanReduce 傳回 true,則應該傳回有效的運算式。If CanReduce returns true, this should return a valid expression. 這個方法可以傳回其他本身必須精簡的節點。This method can return another node which itself must be reduced.

(繼承來源 Expression)
ReduceExtensions()

將運算式精簡為已知的節點類型 (不是 Extension 節點),如果已經是已知的類型,則僅傳回運算式。Reduces the expression to a known node type (that is not an Extension node) or just returns the expression if it is already a known type.

(繼承來源 Expression)
ToString()

傳回 Expression 的文字表示。Returns a textual representation of the Expression.

(繼承來源 Expression)
Update(Expression, IEnumerable<Expression>)

建立類似這個運算式的新運算式,但使用提供的子系。Creates a new expression that is like this one, but using the supplied children. 如果所有子系都相同,則會傳回這個運算式。If all of the children are the same, it will return this expression.

VisitChildren(ExpressionVisitor)

精簡節點,然後呼叫精簡後的運算式上的訪問項委派。Reduces the node and then calls the visitor delegate on the reduced expression. 如果節點無法縮減,此方法會擲回例外狀況。The method throws an exception if the node is not reducible.

(繼承來源 Expression)

明確介面實作

IArgumentProvider.ArgumentCount

傳回運算式樹狀節點的引數數目。Returns the number of arguments to the expression tree node. 您不應該使用這個成員。You should not use this member. 它只有在組件重構時為公用,且使用於內部以取得效能最佳化。It is only public due to assembly refactoring, and it is used internally for performance optimizations.

IArgumentProvider.GetArgument(Int32)

傳回位於索引的引數,如果索引超出範圍則擲回引數。Returns the argument at index, throwing if index is out of bounds. 您不應該使用這個成員。You should not use this member. 它只有在組件重構時為公用,且使用於內部以取得效能最佳化。It is only public due to assembly refactoring, and it is used internally for performance optimizations.

適用於