ParameterExpression Classe
Definição
Representa uma expressão de parâmetro nomeada.Represents a named parameter expression.
public ref class ParameterExpression : System::Linq::Expressions::Expression
public ref class ParameterExpression sealed : System::Linq::Expressions::Expression
public class ParameterExpression : System.Linq.Expressions.Expression
public sealed class ParameterExpression : System.Linq.Expressions.Expression
type ParameterExpression = class
inherit Expression
Public Class ParameterExpression
Inherits Expression
Public NotInheritable Class ParameterExpression
Inherits Expression
- Herança
Exemplos
O exemplo a seguir demonstra como criar um MethodCallExpression objeto que imprime o valor de um ParameterExpression objeto usando o Parameter método.The following example demonstrates how to create a MethodCallExpression object that prints the value of a ParameterExpression object by using the Parameter method.
// Add the following directive to the file:
// using System.Linq.Expressions;
// Creating a parameter for the expression tree.
ParameterExpression param = Expression.Parameter(typeof(int));
// Creating an expression for the method call and specifying its parameter.
MethodCallExpression methodCall = Expression.Call(
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(int) }),
param
);
// The following statement first creates an expression tree,
// then compiles it, and then runs it.
Expression.Lambda<Action<int>>(
methodCall,
new ParameterExpression[] { param }
).Compile()(10);
// This code example produces the following output:
//
// 10
' Add the following directive to the file:
' Imports System.Linq.Expressions
' Creating a parameter for the expression tree.
Dim param As ParameterExpression = Expression.Parameter(GetType(Integer))
' Creating an expression for the method call and specifying its parameter.
Dim methodCall As MethodCallExpression = Expression.Call(
GetType(Console).GetMethod("WriteLine", New Type() {GetType(Integer)}),
param
)
' Compiling and invoking the methodCall expression.
Expression.Lambda(Of Action(Of Integer))(
methodCall,
New ParameterExpression() {param}
).Compile()(10)
' This code example produces the following output:
'
' 10
Comentários
Use o Parameter método de fábrica para criar um ParameterExpression .Use the Parameter factory method to create a ParameterExpression.
O valor da NodeType propriedade de um ParameterExpression objeto é Parameter .The value of the NodeType property of a ParameterExpression object is Parameter.
Propriedades
| CanReduce |
Indica que o nó pode ser reduzido a um nó mais simples.Indicates that the node can be reduced to a simpler node. Se isso retornar verdadeiro, Reduce() poderá ser chamado para produzir a forma reduzida.If this returns true, Reduce() can be called to produce the reduced form. (Herdado de Expression) |
| IsByRef |
Indica que esta |
| Name |
Obtém o nome do parâmetro ou variável.Gets the name of the parameter or variable. |
| NodeType |
Retorna o tipo de nó deste Expression.Returns the node type of this Expression. |
| NodeType |
Obtém o tipo de nó deste Expression.Gets the node type of this Expression. (Herdado de Expression) |
| Type |
Obtém o tipo estático da expressão que esse Expression representa.Gets the static type of the expression that this Expression represents. |
| Type |
Obtém o tipo estático da expressão que esse Expression representa.Gets the static type of the expression that this Expression represents. (Herdado de Expression) |
Métodos
| Accept(ExpressionVisitor) |
Expede o método específico de visita para esse tipo de nó.Dispatches to the specific visit method for this node type. Por exemplo, MethodCallExpression chama o VisitMethodCall(MethodCallExpression).For example, MethodCallExpression calls the VisitMethodCall(MethodCallExpression). |
| Accept(ExpressionVisitor) |
Expede o método específico de visita para esse tipo de nó.Dispatches to the specific visit method for this node type. Por exemplo, MethodCallExpression chama o VisitMethodCall(MethodCallExpression).For example, MethodCallExpression calls the VisitMethodCall(MethodCallExpression). (Herdado de Expression) |
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| Reduce() |
Reduz esse nó a uma expressão mais simples.Reduces this node to a simpler expression. Se CanReduce retornar true, ele deverá retornar uma expressão válida.If CanReduce returns true, this should return a valid expression. Esse método pode retornar outro nó que também precisa ser reduzido.This method can return another node which itself must be reduced. (Herdado de Expression) |
| ReduceAndCheck() |
Reduz esse nó a uma expressão mais simples.Reduces this node to a simpler expression. Se CanReduce retornar true, ele deverá retornar uma expressão válida.If CanReduce returns true, this should return a valid expression. Esse método pode retornar outro nó que também precisa ser reduzido.This method can return another node which itself must be reduced. (Herdado de Expression) |
| ReduceExtensions() |
Reduz a expressão a um tipo de nó conhecido (que não é um nó de extensão) ou apenas retorna a expressão se ele já é um tipo conhecido.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. (Herdado de Expression) |
| ToString() |
Retorna uma representação textual de Expression.Returns a textual representation of the Expression. (Herdado de Expression) |
| VisitChildren(ExpressionVisitor) |
Reduz o nó e, em seguida, chama o delegado visitante na expressão reduzida.Reduces the node and then calls the visitor delegate on the reduced expression. O método gera uma exceção se o nó não é reduzível.The method throws an exception if the node is not reducible. (Herdado de Expression) |