Show / Hide Table of Contents

Class EntityTypeSubstitutor

Replaces entity types with anonymous or record types.

Inheritance
System.Object
ScopedExpressionVisitorBase
ScopedExpressionVisitor<System.Linq.Expressions.ParameterExpression>
ExpressionVisitorWithReflection
TypeSubstitutionExpressionVisitor
EntityTypeSubstitutor
Inherited Members
TypeSubstitutionExpressionVisitor.VisitMember(MemberInfo)
TypeSubstitutionExpressionVisitor.VisitConstructor(ConstructorInfo)
TypeSubstitutionExpressionVisitor.VisitProperty(PropertyInfo)
TypeSubstitutionExpressionVisitor.VisitField(FieldInfo)
TypeSubstitutionExpressionVisitor.VisitMethod(MethodInfo)
TypeSubstitutionExpressionVisitor.VisitDynamic(DynamicExpression)
TypeSubstitutionExpressionVisitor.VisitType(Type)
TypeSubstitutionExpressionVisitor.ConvertExpression(Expression, Expression, Type)
TypeSubstitutionExpressionVisitor.ResolveConstructor(ConstructorInfo, Type, Type[])
TypeSubstitutionExpressionVisitor.ResolveMethod(MethodInfo, Type, Type[], Type[], Type)
TypeSubstitutionExpressionVisitor.Visit(Expression)
TypeSubstitutionExpressionVisitor.MakeConstant(Object, Type)
ExpressionVisitorWithReflection.VisitBinary(BinaryExpression)
ExpressionVisitorWithReflection.MakeBinary(ExpressionType, Expression, Expression, Boolean, MethodInfo, LambdaExpression)
ExpressionVisitorWithReflection.VisitBlockCore(BlockExpression)
ExpressionVisitorWithReflection.MakeBlock(Type, IEnumerable<ParameterExpression>, IEnumerable<Expression>)
ExpressionVisitorWithReflection.VisitCatchBlockCore(CatchBlock)
ExpressionVisitorWithReflection.MakeCatchBlock(Type, ParameterExpression, Expression, Expression)
ExpressionVisitorWithReflection.VisitConditional(ConditionalExpression)
ExpressionVisitorWithReflection.MakeConditional(Expression, Expression, Expression, Type)
ExpressionVisitorWithReflection.VisitConstant(ConstantExpression)
ExpressionVisitorWithReflection.VisitDefault(DefaultExpression)
ExpressionVisitorWithReflection.MakeDefault(Type)
ExpressionVisitorWithReflection.MakeDynamic(CallSiteBinder, Type, IEnumerable<Expression>)
ExpressionVisitorWithReflection.VisitElementInit(ElementInit)
ExpressionVisitorWithReflection.MakeElementInit(MethodInfo, IEnumerable<Expression>)
ExpressionVisitorWithReflection.VisitGoto(GotoExpression)
ExpressionVisitorWithReflection.MakeGoto(GotoExpressionKind, LabelTarget, Expression, Type)
ExpressionVisitorWithReflection.VisitIndex(IndexExpression)
ExpressionVisitorWithReflection.MakeIndex(Expression, PropertyInfo, IEnumerable<Expression>)
ExpressionVisitorWithReflection.VisitInvocation(InvocationExpression)
ExpressionVisitorWithReflection.MakeInvocation(Expression, IEnumerable<Expression>)
ExpressionVisitorWithReflection.VisitLabel(LabelExpression)
ExpressionVisitorWithReflection.MakeLabel(LabelTarget, Expression)
ExpressionVisitorWithReflection.VisitLabelTarget(LabelTarget)
ExpressionVisitorWithReflection.MakeLabelTarget(Type, String)
ExpressionVisitorWithReflection.VisitLambdaCore<T>(Expression<T>)
ExpressionVisitorWithReflection.MakeLambda(Type, Expression, String, Boolean, IEnumerable<ParameterExpression>)
ExpressionVisitorWithReflection.VisitListInit(ListInitExpression)
ExpressionVisitorWithReflection.MakeListInit(NewExpression, IEnumerable<ElementInit>)
ExpressionVisitorWithReflection.VisitLoop(LoopExpression)
ExpressionVisitorWithReflection.MakeLoop(Expression, LabelTarget, LabelTarget)
ExpressionVisitorWithReflection.VisitMember(MemberExpression)
ExpressionVisitorWithReflection.MakeMember(Expression, MemberInfo)
ExpressionVisitorWithReflection.VisitMemberAssignment(MemberAssignment)
ExpressionVisitorWithReflection.MakeMemberAssignment(MemberInfo, Expression)
ExpressionVisitorWithReflection.MakeMemberInit(NewExpression, IEnumerable<MemberBinding>)
ExpressionVisitorWithReflection.VisitMemberListBinding(MemberListBinding)
ExpressionVisitorWithReflection.MakeMemberListBinding(MemberInfo, IEnumerable<ElementInit>)
ExpressionVisitorWithReflection.VisitMemberMemberBinding(MemberMemberBinding)
ExpressionVisitorWithReflection.MakeMemberMemberBinding(MemberInfo, IEnumerable<MemberBinding>)
ExpressionVisitorWithReflection.VisitMethodCall(MethodCallExpression)
ExpressionVisitorWithReflection.MakeMethodCall(Expression, MethodInfo, IEnumerable<Expression>)
ExpressionVisitorWithReflection.MakeNew(ConstructorInfo, IEnumerable<Expression>, IEnumerable<MemberInfo>)
ExpressionVisitorWithReflection.MakeNew(Type)
ExpressionVisitorWithReflection.VisitNewArray(NewArrayExpression)
ExpressionVisitorWithReflection.MakeNewArray(ExpressionType, Type, IEnumerable<Expression>)
ExpressionVisitorWithReflection.VisitParameter(ParameterExpression)
ExpressionVisitorWithReflection.GetState(ParameterExpression)
ExpressionVisitorWithReflection.VisitRuntimeVariables(RuntimeVariablesExpression)
ExpressionVisitorWithReflection.MakeRuntimeVariables(IEnumerable<ParameterExpression>)
ExpressionVisitorWithReflection.VisitSwitch(SwitchExpression)
ExpressionVisitorWithReflection.MakeSwitch(Type, Expression, Expression, MethodInfo, IEnumerable<SwitchCase>)
ExpressionVisitorWithReflection.VisitSwitchCase(SwitchCase)
ExpressionVisitorWithReflection.MakeSwitchCase(Expression, IEnumerable<Expression>)
ExpressionVisitorWithReflection.VisitTry(TryExpression)
ExpressionVisitorWithReflection.MakeTry(Type, Expression, Expression, Expression, IEnumerable<CatchBlock>)
ExpressionVisitorWithReflection.VisitTypeBinary(TypeBinaryExpression)
ExpressionVisitorWithReflection.MakeTypeBinary(ExpressionType, Expression, Type)
ExpressionVisitorWithReflection.VisitUnary(UnaryExpression)
ExpressionVisitorWithReflection.MakeUnary(ExpressionType, Expression, Type, MethodInfo)
ExpressionVisitorWithReflection.VisitBinder(CallSiteBinder)
ExpressionVisitorWithReflection.VisitIfNotNull<T>(T, Func<T, T>)
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.VisitCatchBlock(CatchBlock)
ScopedExpressionVisitorBase.VisitLambda<T>(Expression<T>)
Namespace: Nuqleon.DataModel.CompilerServices
Assembly: Nuqleon.DataModel.CompilerServices.dll
Syntax
public abstract class EntityTypeSubstitutor : TypeSubstitutionExpressionVisitor

Constructors

EntityTypeSubstitutor(IDictionary<Type, Type>)

Create an entity type substitutor.

Declaration
protected EntityTypeSubstitutor(IDictionary<Type, Type> typeMap)
Parameters
Type Name Description
System.Collections.Generic.IDictionary<System.Type, System.Type> typeMap

A map to use to replace types.

Properties

ConstantsMap

Gets a reference to the constants map of converted constant values.

Declaration
public IDictionary<object, object> ConstantsMap { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<System.Object, System.Object>

Parent

The parent of this type substitution visitor, which has an Apply method to first check for previously unencountered entity types, and add them to the type substitution dictionary.

Declaration
public ExpressionEntityTypeSubstitutor Parent { get; set; }
Property Value
Type Description
ExpressionEntityTypeSubstitutor

TypeMap

Gets a reference to the type map so that mappings can be added.

Declaration
public IDictionary<Type, Type> TypeMap { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<System.Type, System.Type>

Methods

Apply(Expression)

Transforms an expression by replacing entity types.

Declaration
public override Expression Apply(Expression expression)
Parameters
Type Name Description
System.Linq.Expressions.Expression expression

The expression to transform.

Returns
Type Description
System.Linq.Expressions.Expression

An expression with entity types replaced.

Overrides
TypeSubstitutionExpressionVisitor.Apply(Expression)

ConvertConstant(Object, DataType, DataType)

Converts a constant from one data type to another.

Declaration
protected virtual object ConvertConstant(object originalValue, DataType oldDataType, DataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

DataType oldDataType

Old data type.

DataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstant(Object, Type)

Converts a constant of a rewritten type into a new type.

Declaration
protected override object ConvertConstant(object originalValue, Type newType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

System.Type newType

New type to convert to.

Returns
Type Description
System.Object

Converted constant.

Overrides
TypeSubstitutionExpressionVisitor.ConvertConstant(Object, Type)

ConvertConstantArray(Object, ArrayDataType, ArrayDataType)

Converts a constant from one array data type to another.

Declaration
protected virtual object ConvertConstantArray(object originalValue, ArrayDataType oldDataType, ArrayDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

ArrayDataType oldDataType

Old data type.

ArrayDataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantCustom(Object, DataType, DataType)

Converts a constant from one custom data type to another.

Declaration
protected virtual object ConvertConstantCustom(object originalValue, DataType oldDataType, DataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

DataType oldDataType

Old data type.

DataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantFunction(Object, FunctionDataType, FunctionDataType)

Converts a constant from one function data type to another.

Declaration
protected virtual object ConvertConstantFunction(object originalValue, FunctionDataType oldDataType, FunctionDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

FunctionDataType oldDataType

Old data type.

FunctionDataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantPrimitive(Object, PrimitiveDataType, PrimitiveDataType)

Converts a constant from one primitive data type to another.

Declaration
protected virtual object ConvertConstantPrimitive(object originalValue, PrimitiveDataType oldDataType, PrimitiveDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

PrimitiveDataType oldDataType

Old data type.

PrimitiveDataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantQuotation(Object, QuotationDataType, QuotationDataType)

Converts a constant from one quotation data type to another.

Declaration
protected virtual object ConvertConstantQuotation(object originalValue, QuotationDataType oldDataType, QuotationDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

QuotationDataType oldDataType

Old data type.

QuotationDataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantStructural(Object, StructuralDataType, StructuralDataType)

Converts a constant from one structural data type to another data type.

Declaration
protected virtual object ConvertConstantStructural(object originalValue, StructuralDataType oldDataType, StructuralDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

StructuralDataType oldDataType

Old data type.

StructuralDataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantStructuralAnonymous(Object, StructuralDataType, StructuralDataType)

Converts a constant from one anonymous data type to another anonymous data type.

Declaration
protected virtual object ConvertConstantStructuralAnonymous(object originalValue, StructuralDataType oldDataType, StructuralDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

StructuralDataType oldDataType

Old anonymous data type.

StructuralDataType newDataType

New anonymous data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantStructuralByPropertyOrderInstantiation(Object, StructuralDataType, StructuralDataType)

Converts a constant by instantiating the new data type based on the converted values of the original data type's properties, in declaration order.

Declaration
protected object ConvertConstantStructuralByPropertyOrderInstantiation(object originalValue, StructuralDataType oldDataType, StructuralDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

StructuralDataType oldDataType

Old data type.

StructuralDataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

Remarks

Anonymous types and tuple data types obey to the prerequisite of property ordering according to the constructor parameter list.

ConvertConstantStructuralCore(Object, StructuralDataType, StructuralDataType)

Converts a constant from one structural data type to another data type. This method is called when the structural type kind needs to change.

Declaration
protected abstract object ConvertConstantStructuralCore(object originalValue, StructuralDataType oldDataType, StructuralDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

StructuralDataType oldDataType

Old data type.

StructuralDataType newDataType

New data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantStructuralRecord(Object, StructuralDataType, StructuralDataType)

Converts a constant from one record data type to another record data type.

Declaration
protected virtual object ConvertConstantStructuralRecord(object originalValue, StructuralDataType oldDataType, StructuralDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

StructuralDataType oldDataType

Old record data type.

StructuralDataType newDataType

New record data type.

Returns
Type Description
System.Object

Converted constant.

ConvertConstantStructuralTuple(Object, StructuralDataType, StructuralDataType)

Converts a constant from one tuple data type to another tuple data type.

Declaration
protected virtual object ConvertConstantStructuralTuple(object originalValue, StructuralDataType oldDataType, StructuralDataType newDataType)
Parameters
Type Name Description
System.Object originalValue

Original value to convert.

StructuralDataType oldDataType

Old tuple data type.

StructuralDataType newDataType

New tuple data type.

Returns
Type Description
System.Object

Converted constant.

CreateNewExpression(Type, IDictionary<MemberInfo, Expression>)

Creates a new expression to instantiate the given type using the specified member assignments.

Declaration
protected abstract Expression CreateNewExpression(Type type, IDictionary<MemberInfo, Expression> memberAssignments)
Parameters
Type Name Description
System.Type type

Type to instantiate.

System.Collections.Generic.IDictionary<System.Reflection.MemberInfo, System.Linq.Expressions.Expression> memberAssignments

Member assignments to carry out.

Returns
Type Description
System.Linq.Expressions.Expression

New expression for the instantiation of the given type using the specified member assignments.

FailResolveConstructor(ConstructorInfo, Type, Type[])

Reports failure of resolving a constructor after retargeting types, offering a last chance opportunity to resolve the constructor.

Declaration
protected override ConstructorInfo FailResolveConstructor(ConstructorInfo originalConstructor, Type declaringType, Type[] parameters)
Parameters
Type Name Description
System.Reflection.ConstructorInfo originalConstructor

Original constructor.

System.Type declaringType

Retargeted declaring type.

System.Type[] parameters

Retargeted parameter types.

Returns
Type Description
System.Reflection.ConstructorInfo

New constructor to use. By default, this method throws an exception to report the resolution failure.

Overrides
TypeSubstitutionExpressionVisitor.FailResolveConstructor(ConstructorInfo, Type, Type[])
Exceptions
Type Condition
System.InvalidOperationException

Thrown to report the resolution failure.

FailResolveField(FieldInfo, Type, Type)

Reports failure of resolving a field after retargeting types, offering a last chance opportunity to resolve the field.

Declaration
protected override MemberInfo FailResolveField(FieldInfo originalField, Type declaringType, Type fieldType)
Parameters
Type Name Description
System.Reflection.FieldInfo originalField

Original field.

System.Type declaringType

Retargeted declaring type.

System.Type fieldType

Retargeted field type.

Returns
Type Description
System.Reflection.MemberInfo

New field to use. By default, this method throws an exception to report the resolution failure.

Overrides
TypeSubstitutionExpressionVisitor.FailResolveField(FieldInfo, Type, Type)
Exceptions
Type Condition
System.InvalidOperationException

Thrown to report the resolution failure.

FailResolveMethod(MethodInfo, Type, Type[], Type[], Type)

Reports failure of resolving a method after retargeting types, offering a last chance opportunity to resolve the method.

Declaration
protected override MethodInfo FailResolveMethod(MethodInfo originalMethod, Type declaringType, Type[] genericArguments, Type[] parameters, Type returnType)
Parameters
Type Name Description
System.Reflection.MethodInfo originalMethod

Original method.

System.Type declaringType

Retargeted declaring type.

System.Type[] genericArguments

Retargeted generic argument types.

System.Type[] parameters

Retargeted parameter types.

System.Type returnType

Retargeted return type.

Returns
Type Description
System.Reflection.MethodInfo

New method to use. By default, this method throws an exception to report the resolution failure.

Overrides
TypeSubstitutionExpressionVisitor.FailResolveMethod(MethodInfo, Type, Type[], Type[], Type)
Exceptions
Type Condition
System.InvalidOperationException

Thrown to report the resolution failure.

FailResolveProperty(PropertyInfo, Type, Type, Type[])

Reports failure of resolving a property after retargeting types, offering a last chance opportunity to resolve the property.

Declaration
protected override MemberInfo FailResolveProperty(PropertyInfo originalProperty, Type declaringType, Type propertyType, Type[] indexerParameters)
Parameters
Type Name Description
System.Reflection.PropertyInfo originalProperty

Original property.

System.Type declaringType

Retargeted declaring type.

System.Type propertyType

Retargeted property type.

System.Type[] indexerParameters

Retargeted indexer parameter types.

Returns
Type Description
System.Reflection.MemberInfo

New property to use. By default, this method throws an exception to report the resolution failure.

Overrides
TypeSubstitutionExpressionVisitor.FailResolveProperty(PropertyInfo, Type, Type, Type[])
Exceptions
Type Condition
System.InvalidOperationException

Thrown to report the resolution failure.

ResolveField(FieldInfo, Type, Type)

Resolves a field after retargeting types.

Declaration
protected override MemberInfo ResolveField(FieldInfo originalField, Type declaringType, Type fieldType)
Parameters
Type Name Description
System.Reflection.FieldInfo originalField

Original field.

System.Type declaringType

Retargeted declaring type.

System.Type fieldType

Retargeted field type.

Returns
Type Description
System.Reflection.MemberInfo

New field to use.

Overrides
TypeSubstitutionExpressionVisitor.ResolveField(FieldInfo, Type, Type)

ResolveProperty(PropertyInfo, Type, Type, Type[])

Resolves a property after retargeting types.

Declaration
protected override MemberInfo ResolveProperty(PropertyInfo originalProperty, Type declaringType, Type propertyType, Type[] indexerParameters)
Parameters
Type Name Description
System.Reflection.PropertyInfo originalProperty

Original property.

System.Type declaringType

Retargeted declaring type.

System.Type propertyType

Retargeted property type.

System.Type[] indexerParameters

Retargeted indexer parameter types.

Returns
Type Description
System.Reflection.MemberInfo

New property to use.

Overrides
TypeSubstitutionExpressionVisitor.ResolveProperty(PropertyInfo, Type, Type, Type[])

ResolveType(Type)

Resolves a type for rewriting of the expression tree.

Declaration
protected override Type ResolveType(Type originalType)
Parameters
Type Name Description
System.Type originalType

Original type.

Returns
Type Description
System.Type

New type to use.

Overrides
TypeSubstitutionExpressionVisitor.ResolveType(Type)

VisitMemberInit(MemberInitExpression)

Visits member initializer expressions and transforms occurrences of entity types.

Declaration
protected override Expression VisitMemberInit(MemberInitExpression node)
Parameters
Type Name Description
System.Linq.Expressions.MemberInitExpression node

The expression to transform.

Returns
Type Description
System.Linq.Expressions.Expression

The new expression with entity types replaced.

Overrides
ExpressionVisitorWithReflection.VisitMemberInit(MemberInitExpression)

VisitMemberInitStructuralDataType(MemberInitExpression, Type, StructuralDataType)

Visit member initializer expressions for structural data types and transforms occurrences of entity types.

Declaration
protected virtual Expression VisitMemberInitStructuralDataType(MemberInitExpression node, Type oldType, StructuralDataType newDataType)
Parameters
Type Name Description
System.Linq.Expressions.MemberInitExpression node

The expression to transform.

System.Type oldType

The original type of the member initializer expression.

StructuralDataType newDataType

The new data type of the member initializer expression.

Returns
Type Description
System.Linq.Expressions.Expression

The member initializer expression with the original type replaced with the new type.

VisitNew(NewExpression)

Visits new expressions and transforms occurrences of entity types.

Declaration
protected override Expression VisitNew(NewExpression node)
Parameters
Type Name Description
System.Linq.Expressions.NewExpression node

The expression to transform.

Returns
Type Description
System.Linq.Expressions.Expression

The new expression with entity types replaced.

Overrides
ExpressionVisitorWithReflection.VisitNew(NewExpression)

VisitNewStructuralDataType(NewExpression, Type, StructuralDataType)

Visit new expressions for structural data types and transforms occurrences of entity types.

Declaration
protected virtual Expression VisitNewStructuralDataType(NewExpression node, Type oldType, StructuralDataType newDataType)
Parameters
Type Name Description
System.Linq.Expressions.NewExpression node

The expression to transform.

System.Type oldType

The original type of the new expression.

StructuralDataType newDataType

The new data type of the new expression.

Returns
Type Description
System.Linq.Expressions.Expression

The new expression with the original type replaced with the new type.

In This Article
Back to top Generated by DocFX