Show / Hide Table of Contents

Class TypeBasedExpressionRewriter

An expression rewriter that rewrites using a set of user defined lambdas that are applied when the runtime type of the expression matches the user supplied value.

Inheritance
System.Object
ScopedExpressionVisitorBase
ScopedExpressionVisitor<System.Linq.Expressions.ParameterExpression>
TypeBasedExpressionRewriter
Inherited Members
ScopedExpressionVisitor<ParameterExpression>.TryLookup(ParameterExpression, ParameterExpression)
ScopedExpressionVisitor<ParameterExpression>.Push(IEnumerable<ParameterExpression>)
ScopedExpressionVisitor<ParameterExpression>.Push(IEnumerable<KeyValuePair<ParameterExpression, ParameterExpression>>)
ScopedExpressionVisitor<ParameterExpression>.Pop()
ScopedExpressionVisitor<ParameterExpression>.GlobalScope
ScopedExpressionVisitorBase.VisitBlock(BlockExpression)
ScopedExpressionVisitorBase.VisitBlockCore(BlockExpression)
ScopedExpressionVisitorBase.VisitCatchBlock(CatchBlock)
ScopedExpressionVisitorBase.VisitCatchBlockCore(CatchBlock)
ScopedExpressionVisitorBase.VisitLambda<T>(Expression<T>)
ScopedExpressionVisitorBase.VisitLambdaCore<T>(Expression<T>)
Namespace: System.Linq.CompilerServices
Assembly: Nuqleon.Linq.CompilerServices.dll
Syntax
public class TypeBasedExpressionRewriter : ScopedExpressionVisitor<ParameterExpression>

Constructors

TypeBasedExpressionRewriter()

Instantiates the type-based expression rewriter.

Declaration
public TypeBasedExpressionRewriter()

Methods

Add(Type, Func<Expression, Expression>)

Adds a rewriter for a specified type. The user supplied rewriter is applied whenever an expression type can be assigned to the user supplied type.

Declaration
public void Add(Type type, Func<Expression, Expression> rewriter)
Parameters
Type Name Description
System.Type type

The type that triggers the rewriter.

System.Func<System.Linq.Expressions.Expression, System.Linq.Expressions.Expression> rewriter

The expression rewriter.

AddDefinition(Type, Func<Expression, Expression>)

Adds a rewriter for a specified generic type definition. The user supplied rewriter is applied whenever an expression type implements or extends some closure over the user supplied generic type definition.

Declaration
public void AddDefinition(Type type, Func<Expression, Expression> rewriter)
Parameters
Type Name Description
System.Type type

The type that triggers the rewriter.

System.Func<System.Linq.Expressions.Expression, System.Linq.Expressions.Expression> rewriter

The expression rewriter.

GetState(ParameterExpression)

Maps the specified parameter on state tracked in the scoped symbol table. This method gets called for each declaration site of a variable.

Declaration
protected override ParameterExpression GetState(ParameterExpression parameter)
Parameters
Type Name Description
System.Linq.Expressions.ParameterExpression parameter

Parameter expression that's being declared.

Returns
Type Description
System.Linq.Expressions.ParameterExpression

State to associate with the given parameter.

Overrides
System.Linq.CompilerServices.ScopedExpressionVisitor<System.Linq.Expressions.ParameterExpression>.GetState(System.Linq.Expressions.ParameterExpression)

Visit(Expression)

Visits an expression, looping over the list of user supplied rewriters, and rewriting the expression if the expression type matches any of the supplied rewriters.

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

The expression.

Returns
Type Description
System.Linq.Expressions.Expression

The result of the visit.

In This Article
Back to top Generated by DocFX