Class EntityTypeSlimSubstitutor
Replaces entity types with anonymous or record types.
Inheritance
Inherited Members
Namespace: Nuqleon.DataModel.CompilerServices.Bonsai
Assembly: Nuqleon.DataModel.CompilerServices.dll
Syntax
public abstract class EntityTypeSlimSubstitutor : TypeSubstitutionExpressionSlimVisitor
Constructors
EntityTypeSlimSubstitutor(IDictionary<TypeSlim, TypeSlim>)
Create an entity type substitutor.
Declaration
protected EntityTypeSlimSubstitutor(IDictionary<TypeSlim, TypeSlim> typeMap)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TypeSlim, TypeSlim> | 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 ExpressionSlimEntityTypeSubstitutor Parent { get; set; }
Property Value
| Type | Description |
|---|---|
| ExpressionSlimEntityTypeSubstitutor |
TypeMap
Gets a reference to the type map so that mappings can be added.
Declaration
public IDictionary<TypeSlim, TypeSlim> TypeMap { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<TypeSlim, TypeSlim> |
Methods
Apply(ExpressionSlim)
Transforms an expression by replacing entity types.
Declaration
public override ExpressionSlim Apply(ExpressionSlim expression)
Parameters
| Type | Name | Description |
|---|---|---|
| ExpressionSlim | expression | The expression to transform. |
Returns
| Type | Description |
|---|---|
| ExpressionSlim | 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(ObjectSlim, TypeSlim)
Converts a constant of a rewritten type into a new type.
Declaration
protected override ObjectSlim ConvertConstant(ObjectSlim originalValue, TypeSlim newType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.ObjectSlim | originalValue | Original value to convert. |
| TypeSlim | newType | New type to convert to. |
Returns
| Type | Description |
|---|---|
| System.ObjectSlim | 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(TypeSlim, IDictionary<MemberInfoSlim, ExpressionSlim>)
Creates a new expression to instantiate the given type using the specified member assignments.
Declaration
protected abstract ExpressionSlim CreateNewExpression(TypeSlim type, IDictionary<MemberInfoSlim, ExpressionSlim> memberAssignments)
Parameters
| Type | Name | Description |
|---|---|---|
| TypeSlim | type | Type to instantiate. |
| System.Collections.Generic.IDictionary<MemberInfoSlim, ExpressionSlim> | memberAssignments | Member assignments to carry out. |
Returns
| Type | Description |
|---|---|
| ExpressionSlim | New expression for the instantiation of the given type using the specified member assignments. |
ResolveField(FieldInfoSlim, TypeSlim, TypeSlim)
Resolves a field after retargeting types.
Declaration
protected override MemberInfoSlim ResolveField(FieldInfoSlim originalField, TypeSlim declaringType, TypeSlim fieldType)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfoSlim | originalField | Original field. |
| TypeSlim | declaringType | Retargeted declaring type. |
| TypeSlim | fieldType | Retargeted field type. |
Returns
| Type | Description |
|---|---|
| MemberInfoSlim | New member to use. |
Overrides
ResolveProperty(PropertyInfoSlim, TypeSlim, TypeSlim, TypeSlim[])
Resolves a property after retargeting types.
Declaration
protected override MemberInfoSlim ResolveProperty(PropertyInfoSlim originalProperty, TypeSlim declaringType, TypeSlim propertyType, TypeSlim[] indexerParameters)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyInfoSlim | originalProperty | Original property. |
| TypeSlim | declaringType | Retargeted declaring type. |
| TypeSlim | propertyType | Retargeted property type. |
| TypeSlim[] | indexerParameters | Retargeted indexer parameter types. |
Returns
| Type | Description |
|---|---|
| MemberInfoSlim | New property to use. |
Overrides
ResolveType(TypeSlim)
Resolves a type for rewriting of the expression tree.
Declaration
protected override TypeSlim ResolveType(TypeSlim originalType)
Parameters
| Type | Name | Description |
|---|---|---|
| TypeSlim | originalType | Original type. |
Returns
| Type | Description |
|---|---|
| TypeSlim | New type to use. |
Overrides
VisitMemberInit(MemberInitExpressionSlim)
Visits member initializer expressions and transforms occurrences of entity types.
Declaration
protected override ExpressionSlim VisitMemberInit(MemberInitExpressionSlim node)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInitExpressionSlim | node | The expression to transform. |
Returns
| Type | Description |
|---|---|
| ExpressionSlim | The new expression with entity types replaced. |
Overrides
VisitMemberInitStructuralDataType(MemberInitExpressionSlim, StructuralTypeSlim)
Visit member initializer expressions for structural data types and transforms occurrences of entity types.
Declaration
protected virtual ExpressionSlim VisitMemberInitStructuralDataType(MemberInitExpressionSlim node, StructuralTypeSlim newStructuralType)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInitExpressionSlim | node | The expression to transform. |
| StructuralTypeSlim | newStructuralType | The new structural type. |
Returns
| Type | Description |
|---|---|
| ExpressionSlim | The member initializer expression with the original type replaced with the new type. |
VisitNew(NewExpressionSlim)
Visits new expressions and transforms occurrences of entity types.
Declaration
protected override ExpressionSlim VisitNew(NewExpressionSlim node)
Parameters
| Type | Name | Description |
|---|---|---|
| NewExpressionSlim | node | The expression to transform. |
Returns
| Type | Description |
|---|---|
| ExpressionSlim | The new expression with entity types replaced. |
Overrides
VisitNewStructuralDataType(NewExpressionSlim, StructuralTypeSlim)
Visit new expressions for structural data types and transforms occurrences of entity types.
Declaration
protected virtual ExpressionSlim VisitNewStructuralDataType(NewExpressionSlim node, StructuralTypeSlim newType)
Parameters
| Type | Name | Description |
|---|---|---|
| NewExpressionSlim | node | The expression to transform. |
| StructuralTypeSlim | newType | The original type of the new expression. |
Returns
| Type | Description |
|---|---|
| ExpressionSlim | The new expression with the original type replaced with the new type. |