Class ExpressionExtensions
Provides a set of extension methods for System.Linq.Expressions.Expression.
Inheritance
Namespace: System.Linq.Expressions
Assembly: Nuqleon.Linq.CompilerServices.dll
Syntax
public static class ExpressionExtensions : Object
Methods
Evaluate(Expression)
Evaluates the specified expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static object Evaluate(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to evaluate. |
Returns
Type | Description |
---|---|
System.Object | Result of evaluating the expression tree. |
Evaluate(Expression, ICompiledDelegateCache)
Evaluates the specified expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static object Evaluate(this Expression expression, ICompiledDelegateCache cache)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to evaluate. |
ICompiledDelegateCache | cache | Compiled delegate cache. |
Returns
Type | Description |
---|---|
System.Object | Result of evaluating the expression tree. |
Evaluate<TResult>(Expression)
Evaluates the specified expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static TResult Evaluate<TResult>(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to evaluate. |
Returns
Type | Description |
---|---|
TResult | Result of evaluating the expression tree. |
Type Parameters
Name | Description |
---|---|
TResult | Type of the evaluation result. |
Evaluate<TResult>(Expression, ICompiledDelegateCache)
Evaluates the specified expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static TResult Evaluate<TResult>(this Expression expression, ICompiledDelegateCache cache)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to evaluate. |
ICompiledDelegateCache | cache | Compiled delegate cache. |
Returns
Type | Description |
---|---|
TResult | Result of evaluating the expression tree. |
Type Parameters
Name | Description |
---|---|
TResult | Type of the evaluation result. |
Evaluate<TResult>(Expression<Func<TResult>>)
Evaluates the specified expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static TResult Evaluate<TResult>(this Expression<Func<TResult>> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TResult>> | expression | Expression to evaluate. |
Returns
Type | Description |
---|---|
TResult | Result of evaluating the expression tree. |
Type Parameters
Name | Description |
---|---|
TResult | Type of the evaluation result. |
Evaluate<TResult>(Expression<Func<TResult>>, ICompiledDelegateCache)
Evaluates the specified expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static TResult Evaluate<TResult>(this Expression<Func<TResult>> expression, ICompiledDelegateCache cache)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TResult>> | expression | Expression to evaluate. |
ICompiledDelegateCache | cache | Compiled delegate cache. |
Returns
Type | Description |
---|---|
TResult | Result of evaluating the expression tree. |
Type Parameters
Name | Description |
---|---|
TResult | Type of the evaluation result. |
Funcletize(Expression)
Creates a funclet expression for the specified expression tree. This funclet can be used to evaluate the expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static Expression<Func<object>> Funcletize(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to funcletize. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression<System.Func<System.Object>> | Funclet to evaluate the expression tree. |
Funcletize<TResult>(Expression)
Creates a funclet expression for the specified expression tree. This funclet can be used to evaluate the expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static Expression<Func<TResult>> Funcletize<TResult>(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to funcletize. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression<System.Func<TResult>> | Funclet to evaluate the expression tree. |
Type Parameters
Name | Description |
---|---|
TResult | Result type of the expression. |
Funcletize<TResult>(Expression<Func<TResult>>)
Creates a funclet expression for the specified expression tree. This funclet can be used to evaluate the expression tree. If the specified expression has unbound parameters, an exception will be thrown.
Declaration
public static Expression<Func<TResult>> Funcletize<TResult>(this Expression<Func<TResult>> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TResult>> | expression | Expression to funcletize. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression<System.Func<TResult>> | Funclet to evaluate the expression tree. |
Type Parameters
Name | Description |
---|---|
TResult | Result type of the expression. |
ToCSharp(Expression)
Converts the specified expression tree to a representation using C# syntax, and acquires constants and globals that occur in the expression tree.
Declaration
public static CSharpExpression ToCSharp(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to provide a C# representation for. |
Returns
Type | Description |
---|---|
CSharpExpression | C# representation of the specified expression tree. |
ToCSharp(Expression, Boolean)
Converts the specified expression tree to a representation using C# syntax, with configurable exposure of compiler-generated names, and acquires constants and globals that occur in the expression tree.
Declaration
public static CSharpExpression ToCSharp(this Expression expression, bool allowCompilerGeneratedNames)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to provide a C# representation for. |
System.Boolean | allowCompilerGeneratedNames | Indicates whether compiler-generated names are allowed in the output. If enabled, the resulting C# syntax may not be syntactically valid. |
Returns
Type | Description |
---|---|
CSharpExpression | C# representation of the specified expression tree. |
ToCSharpString(Expression)
Gets a string representation of the specified expression tree using C# syntax. The resulting string is not guaranteed to be semantically equivalent and should be used for diagnostic purposes only.
Declaration
public static string ToCSharpString(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to provide a C# code fragment for. |
Returns
Type | Description |
---|---|
System.String | String representation of the specified expression tree using C# syntax. |
ToCSharpString(Expression, Boolean)
Gets a string representation of the specified expression tree using C# syntax, with configurable exposure of compiler-generated names. The resulting string is not guaranteed to be semantically equivalent and should be used for diagnostic purposes only.
Declaration
public static string ToCSharpString(this Expression expression, bool allowCompilerGeneratedNames)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to provide a C# code fragment for. |
System.Boolean | allowCompilerGeneratedNames | Indicates whether compiler-generated names are allowed in the output. If enabled, the resulting C# syntax may not be syntactically valid. |
Returns
Type | Description |
---|---|
System.String | String representation of the specified expression tree using C# syntax. |
ToExpressionTree(ElementInit)
Converts an element initializer to an ITree representation that can be used with rewriter tools.
Declaration
public static ElementInitExpressionTree ToExpressionTree(this ElementInit elementInitializer)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ElementInit | elementInitializer | Element initializer to convert. |
Returns
Type | Description |
---|---|
ElementInitExpressionTree | ITree representation of the element initializer. |
ToExpressionTree(Expression)
Converts an expression tree to an ITree representation that can be used with rewriter tools.
Declaration
public static ExpressionTree ToExpressionTree(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression tree to convert. |
Returns
Type | Description |
---|---|
ExpressionTree | ITree representation of the expression tree. |
ToExpressionTree(MemberBinding)
Converts a member binding to an ITree representation that can be used with rewriter tools.
Declaration
public static MemberBindingExpressionTree ToExpressionTree(this MemberBinding memberBinding)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MemberBinding | memberBinding | Member binding to convert. |
Returns
Type | Description |
---|---|
MemberBindingExpressionTree | ITree representation of the member binding. |