Show / Hide Table of Contents

Class ExpressionVisitor<TExpression>

Base class for expression visitors that rewrite an expression tree into a target type.

Inheritance
System.Object
ExpressionVisitor<TExpression>
ExpressionVisitor<TExpression, TLambdaExpression, TParameterExpression, TNewExpression, TElementInit, TMemberBinding, TMemberAssignment, TMemberListBinding, TMemberMemberBinding, TCatchBlock, TSwitchCase, TLabelTarget>
PartialExpressionVisitor<TExpression>
Namespace: System.Linq.CompilerServices
Assembly: Nuqleon.Linq.CompilerServices.dll
Syntax
public abstract class ExpressionVisitor<TExpression> : Object
Type Parameters
Name Description
TExpression

Target type for expressions.

Constructors

ExpressionVisitor()

Declaration
protected ExpressionVisitor()

Methods

Visit(Expression)

Visits the specified expression and rewrites it to the target expression type.

Declaration
public virtual TExpression Visit(Expression node)
Parameters
Type Name Description
System.Linq.Expressions.Expression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

Visit<T>(ReadOnlyCollection<T>)

Visits the collection of expression nodes and rewrites them to the target expression type.

Declaration
protected ReadOnlyCollection<TExpression> Visit<T>(ReadOnlyCollection<T> nodes)
    where T : Expression
Parameters
Type Name Description
System.Collections.ObjectModel.ReadOnlyCollection<T> nodes

Expression nodes to rewrite.

Returns
Type Description
System.Collections.ObjectModel.ReadOnlyCollection<TExpression>

Collection of rewritten expression nodes.

Type Parameters
Name Description
T

Type of the expressions to rewrite. This type should derive from Expression.

VisitAndConvert<TStronglyTypedResult>(Expression)

Visits the specified expression and rewrites it to the specified target expression type.

Declaration
protected TStronglyTypedResult VisitAndConvert<TStronglyTypedResult>(Expression node)
    where TStronglyTypedResult : TExpression
Parameters
Type Name Description
System.Linq.Expressions.Expression node

Expression to visit.

Returns
Type Description
TStronglyTypedResult

Result of visiting the expression.

Type Parameters
Name Description
TStronglyTypedResult

Type of the result of the rewrite. This type should derive from TExpression.

VisitAndConvert<T, TStronglyTypedResult>(ReadOnlyCollection<T>)

Visits the collection of expression nodes and rewrites them to the specified target expression type.

Declaration
protected ReadOnlyCollection<TStronglyTypedResult> VisitAndConvert<T, TStronglyTypedResult>(ReadOnlyCollection<T> nodes)
    where T : Expression where TStronglyTypedResult : TExpression
Parameters
Type Name Description
System.Collections.ObjectModel.ReadOnlyCollection<T> nodes

Expression nodes to rewrite.

Returns
Type Description
System.Collections.ObjectModel.ReadOnlyCollection<TStronglyTypedResult>

Collection of rewritten expression nodes.

Type Parameters
Name Description
T

Type of the expressions to rewrite. This type should derive from Expression.

TStronglyTypedResult

Type of the results of the rewrite. This type should derive from TExpression.

VisitBinary(BinaryExpression)

Visits the children of the BinaryExpression.

Declaration
protected abstract TExpression VisitBinary(BinaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.BinaryExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitBlock(BlockExpression)

Visits the children of the BlockExpression.

Declaration
protected abstract TExpression VisitBlock(BlockExpression node)
Parameters
Type Name Description
System.Linq.Expressions.BlockExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitConditional(ConditionalExpression)

Visits the children of the ConditionalExpression.

Declaration
protected abstract TExpression VisitConditional(ConditionalExpression node)
Parameters
Type Name Description
System.Linq.Expressions.ConditionalExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitConstant(ConstantExpression)

Visits the children of the ConstantExpression.

Declaration
protected abstract TExpression VisitConstant(ConstantExpression node)
Parameters
Type Name Description
System.Linq.Expressions.ConstantExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitDebugInfo(DebugInfoExpression)

Visits the children of the DebugInfoExpression.

Declaration
protected abstract TExpression VisitDebugInfo(DebugInfoExpression node)
Parameters
Type Name Description
System.Linq.Expressions.DebugInfoExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitDefault(DefaultExpression)

Visits the children of the DefaultExpression.

Declaration
protected abstract TExpression VisitDefault(DefaultExpression node)
Parameters
Type Name Description
System.Linq.Expressions.DefaultExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitDynamic(DynamicExpression)

Visits the children of the DynamicExpression.

Declaration
protected abstract TExpression VisitDynamic(DynamicExpression node)
Parameters
Type Name Description
System.Linq.Expressions.DynamicExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitExtension(Expression)

Visits the children of the extension expression node.

Declaration
protected abstract TExpression VisitExtension(Expression node)
Parameters
Type Name Description
System.Linq.Expressions.Expression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitGoto(GotoExpression)

Visits the children of the GotoExpression.

Declaration
protected abstract TExpression VisitGoto(GotoExpression node)
Parameters
Type Name Description
System.Linq.Expressions.GotoExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitIfNotNull<T, TResult>(T, Func<T, TResult>)

Visits the specified node using the specified visitor function if it's not null.

Declaration
protected static TResult VisitIfNotNull<T, TResult>(T node, Func<T, TResult> nodeVisitor)
Parameters
Type Name Description
T node

Node to visit.

System.Func<T, TResult> nodeVisitor

Visitor function to apply to the node.

Returns
Type Description
TResult

Result of applying the visitor function to the node.

Type Parameters
Name Description
T

Type of the node to visit.

TResult

Type of the result of visiting the node.

VisitIndex(IndexExpression)

Visits the children of the IndexExpression.

Declaration
protected abstract TExpression VisitIndex(IndexExpression node)
Parameters
Type Name Description
System.Linq.Expressions.IndexExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitInvocation(InvocationExpression)

Visits the children of the InvocationExpression.

Declaration
protected abstract TExpression VisitInvocation(InvocationExpression node)
Parameters
Type Name Description
System.Linq.Expressions.InvocationExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitLabel(LabelExpression)

Visits the children of the LabelExpression.

Declaration
protected abstract TExpression VisitLabel(LabelExpression node)
Parameters
Type Name Description
System.Linq.Expressions.LabelExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitLambda<T>(Expression<T>)

Visits the children of the LambdaExpression.

Declaration
protected abstract TExpression VisitLambda<T>(Expression<T> node)
Parameters
Type Name Description
System.Linq.Expressions.Expression<T> node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

Type Parameters
Name Description
T

The type of the delegate.

VisitListInit(ListInitExpression)

Visits the children of the ListInitExpression.

Declaration
protected abstract TExpression VisitListInit(ListInitExpression node)
Parameters
Type Name Description
System.Linq.Expressions.ListInitExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitLoop(LoopExpression)

Visits the children of the LoopExpression.

Declaration
protected abstract TExpression VisitLoop(LoopExpression node)
Parameters
Type Name Description
System.Linq.Expressions.LoopExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitMember(MemberExpression)

Visits the children of the MemberExpression.

Declaration
protected abstract TExpression VisitMember(MemberExpression node)
Parameters
Type Name Description
System.Linq.Expressions.MemberExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitMemberInit(MemberInitExpression)

Visits the children of the MemberInitExpression.

Declaration
protected abstract TExpression VisitMemberInit(MemberInitExpression node)
Parameters
Type Name Description
System.Linq.Expressions.MemberInitExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitMethodCall(MethodCallExpression)

Visits the children of the MethodCallExpression.

Declaration
protected abstract TExpression VisitMethodCall(MethodCallExpression node)
Parameters
Type Name Description
System.Linq.Expressions.MethodCallExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitNew(NewExpression)

Visits the children of the NewExpression.

Declaration
protected abstract TExpression VisitNew(NewExpression node)
Parameters
Type Name Description
System.Linq.Expressions.NewExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitNewArray(NewArrayExpression)

Visits the children of the NewArrayExpression.

Declaration
protected abstract TExpression VisitNewArray(NewArrayExpression node)
Parameters
Type Name Description
System.Linq.Expressions.NewArrayExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitParameter(ParameterExpression)

Visits the children of the ParameterExpression.

Declaration
protected abstract TExpression VisitParameter(ParameterExpression node)
Parameters
Type Name Description
System.Linq.Expressions.ParameterExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitRuntimeVariables(RuntimeVariablesExpression)

Visits the children of the RuntimeVariablesExpression.

Declaration
protected abstract TExpression VisitRuntimeVariables(RuntimeVariablesExpression node)
Parameters
Type Name Description
System.Linq.Expressions.RuntimeVariablesExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitSwitch(SwitchExpression)

Visits the children of the SwitchExpression.

Declaration
protected abstract TExpression VisitSwitch(SwitchExpression node)
Parameters
Type Name Description
System.Linq.Expressions.SwitchExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitTry(TryExpression)

Visits the children of the TryExpression.

Declaration
protected abstract TExpression VisitTry(TryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.TryExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitTypeBinary(TypeBinaryExpression)

Visits the children of the TypeBinaryExpression.

Declaration
protected abstract TExpression VisitTypeBinary(TypeBinaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.TypeBinaryExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

VisitUnary(UnaryExpression)

Visits the children of the UnaryExpression.

Declaration
protected abstract TExpression VisitUnary(UnaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.UnaryExpression node

Expression to visit.

Returns
Type Description
TExpression

Result of visiting the expression.

In This Article
Back to top Generated by DocFX