Class EntityTypeSubstitutor
Replaces entity types with anonymous or record types.
Inheritance
Inherited Members
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
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
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
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
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
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
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
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
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
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
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
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. |