Class TypeSubstitutionExpressionSlimVisitor
Visitor to retarget types that occur in an expression tree. Subclasses can customize reflection member resolution.
Inheritance
Inherited Members
Namespace: System.Linq.CompilerServices.Bonsai
Assembly: Nuqleon.Linq.Expressions.Bonsai.dll
Syntax
public class TypeSubstitutionExpressionSlimVisitor : ExpressionSlimVisitorWithReflection
Constructors
TypeSubstitutionExpressionSlimVisitor(IDictionary<TypeSlim, TypeSlim>)
Creates a new type substitution expression visitor with the specified type map.
Declaration
public TypeSubstitutionExpressionSlimVisitor(IDictionary<TypeSlim, TypeSlim> typeMap)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<TypeSlim, TypeSlim> | typeMap | Dictionary to map source types onto target types. |
TypeSubstitutionExpressionSlimVisitor(TypeSlimSubstitutor)
Creates a new type substitution expression visitor with the specified type substitutor.
Declaration
public TypeSubstitutionExpressionSlimVisitor(TypeSlimSubstitutor typeSubstitutor)
Parameters
Type | Name | Description |
---|---|---|
TypeSlimSubstitutor | typeSubstitutor | Type substitutor to map source types onto target types. |
Methods
Apply(ExpressionSlim)
Applies the type substitution to the specified expression.
Declaration
public virtual ExpressionSlim Apply(ExpressionSlim expression)
Parameters
Type | Name | Description |
---|---|---|
ExpressionSlim | expression | Expression to rewrite. |
Returns
Type | Description |
---|---|
ExpressionSlim | Expression with nodes with source types replaced by nodes with the corresponding target types. |
ConvertConstant(ObjectSlim, TypeSlim)
Converts a constant value whose constant expression node's type has changed.
Declaration
protected virtual ObjectSlim ConvertConstant(ObjectSlim originalValue, TypeSlim newType)
Parameters
Type | Name | Description |
---|---|---|
System.ObjectSlim | originalValue | Original value of the constant expression. |
TypeSlim | newType | Resolved target type for the constant. |
Returns
Type | Description |
---|---|
System.ObjectSlim | Object representing the same value as the original value, but using the specified resolved target type. |
ConvertExpression(ExpressionSlim, ExpressionSlim, TypeSlim)
Converts an expression whose type has changed.
Declaration
protected virtual ExpressionSlim ConvertExpression(ExpressionSlim originalExpression, ExpressionSlim resultExpression, TypeSlim newType)
Parameters
Type | Name | Description |
---|---|---|
ExpressionSlim | originalExpression | Original expression. |
ExpressionSlim | resultExpression | Rewritten expression which does not conform to the expected type. |
TypeSlim | newType | Resolved target type for the expression. |
Returns
Type | Description |
---|---|
ExpressionSlim | Expression with the same value as the rewritten expression, but using the specified resolved target type. |
MakeConstant(ObjectSlim, TypeSlim)
Creates a constant expression.
Declaration
protected override ExpressionSlim MakeConstant(ObjectSlim value, TypeSlim type)
Parameters
Type | Name | Description |
---|---|---|
System.ObjectSlim | value | Value of the constant expression. |
TypeSlim | type | Type of the constant expression. |
Returns
Type | Description |
---|---|
ExpressionSlim | New constant expression node. |
Overrides
ResolveConstructor(ConstructorInfoSlim, TypeSlim, TypeSlim[])
Resolves a constructor after retargeting types.
Declaration
protected virtual ConstructorInfoSlim ResolveConstructor(ConstructorInfoSlim originalConstructor, TypeSlim declaringType, TypeSlim[] parameters)
Parameters
Type | Name | Description |
---|---|---|
ConstructorInfoSlim | originalConstructor | Original constructor. |
TypeSlim | declaringType | Retargeted declaring type. |
TypeSlim[] | parameters | Retargeted parameter types. |
Returns
Type | Description |
---|---|
ConstructorInfoSlim | New constructor to use. |
ResolveField(FieldInfoSlim, TypeSlim, TypeSlim)
Resolves a field after retargeting types.
Declaration
protected virtual 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 field to use. |
ResolveMethod(MethodInfoSlim, TypeSlim, TypeSlim[], TypeSlim[], TypeSlim)
Resolves a method after retargeting types.
Declaration
protected virtual MethodInfoSlim ResolveMethod(MethodInfoSlim originalMethod, TypeSlim declaringType, TypeSlim[] genericArguments, TypeSlim[] parameters, TypeSlim returnType)
Parameters
Type | Name | Description |
---|---|---|
MethodInfoSlim | originalMethod | Original method. |
TypeSlim | declaringType | Retargeted declaring type. |
TypeSlim[] | genericArguments | Retargeted generic argument types. |
TypeSlim[] | parameters | Retargeted parameter types. |
TypeSlim | returnType | Retargeted return type. |
Returns
Type | Description |
---|---|
MethodInfoSlim | New method to use. |
ResolveProperty(PropertyInfoSlim, TypeSlim, TypeSlim, TypeSlim[])
Resolves a property after retargeting types.
Declaration
protected virtual 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. |
ResolveType(TypeSlim)
Resolves a type for rewriting of the expression tree.
Declaration
protected virtual TypeSlim ResolveType(TypeSlim originalType)
Parameters
Type | Name | Description |
---|---|---|
TypeSlim | originalType | Original type. |
Returns
Type | Description |
---|---|
TypeSlim | New type to use. |
Visit(ExpressionSlim)
Visits the expression to rewrite types.
Declaration
public override ExpressionSlim Visit(ExpressionSlim node)
Parameters
Type | Name | Description |
---|---|---|
ExpressionSlim | node | Expression to visit. |
Returns
Type | Description |
---|---|
ExpressionSlim | Expression with types rewritten. |
Overrides
VisitConstructor(ConstructorInfoSlim)
Visits a constructor. When overridden, other visit methods should be overridden appropriately to ensure consistent typing.
Declaration
protected override ConstructorInfoSlim VisitConstructor(ConstructorInfoSlim constructor)
Parameters
Type | Name | Description |
---|---|---|
ConstructorInfoSlim | constructor | Constructor to visit. |
Returns
Type | Description |
---|---|
ConstructorInfoSlim | Result of the visit. |
Overrides
VisitField(FieldInfoSlim)
Visits a field. When overridden, other visit methods should be overridden appropriately to ensure consistent typing.
Declaration
protected virtual MemberInfoSlim VisitField(FieldInfoSlim field)
Parameters
Type | Name | Description |
---|---|---|
FieldInfoSlim | field | Field to visit. |
Returns
Type | Description |
---|---|
MemberInfoSlim | Result of the visit. |
VisitMember(MemberInfoSlim)
Visits a member. When overridden, other visit methods should be overridden appropriately to ensure consistent typing.
Declaration
protected override MemberInfoSlim VisitMember(MemberInfoSlim member)
Parameters
Type | Name | Description |
---|---|---|
MemberInfoSlim | member | Member to visit. |
Returns
Type | Description |
---|---|
MemberInfoSlim | Result of the visit. |
Overrides
VisitMethod(MethodInfoSlim)
Visits a method. When overridden, other visit methods should be overridden appropriately to ensure consistent typing.
Declaration
protected override MethodInfoSlim VisitMethod(MethodInfoSlim method)
Parameters
Type | Name | Description |
---|---|---|
MethodInfoSlim | method | Method to visit. |
Returns
Type | Description |
---|---|
MethodInfoSlim | Result of the visit. |
Overrides
VisitProperty(PropertyInfoSlim)
Visits a property. When overridden, other visit methods should be overridden appropriately to ensure consistent typing.
Declaration
protected override MemberInfoSlim VisitProperty(PropertyInfoSlim property)
Parameters
Type | Name | Description |
---|---|---|
PropertyInfoSlim | property | Property to visit. |
Returns
Type | Description |
---|---|
MemberInfoSlim | Result of the visit. |
Overrides
VisitType(TypeSlim)
Visits a type. When overridden, other visit methods should be overridden appropriately to ensure consistent typing.
Declaration
protected override TypeSlim VisitType(TypeSlim type)
Parameters
Type | Name | Description |
---|---|---|
TypeSlim | type | Type to visit. |
Returns
Type | Description |
---|---|
TypeSlim | Result of the visit. |