Class TypeShapeVisitor
- Namespace
- PolyType.Abstractions
- Assembly
- PolyType.dll
Provides a visitor for strongly-typed traversal of .NET types.
public abstract class TypeShapeVisitor
- Inheritance
-
TypeShapeVisitor
- Inherited Members
Remarks
All methods are virtual, and will throw NotImplementedException if not overridden.
Methods
VisitConstructor<TDeclaringType, TArgumentState>(IConstructorShape<TDeclaringType, TArgumentState>, object?)
Visits an IParameterShape<TArgumentState, TParameterType> instance.
public virtual object? VisitConstructor<TDeclaringType, TArgumentState>(IConstructorShape<TDeclaringType, TArgumentState> constructorShape, object? state = null)
Parameters
constructorShape
IConstructorShape<TDeclaringType, TArgumentState>The constructor shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TDeclaringType
The declaring type of the visited constructor.
TArgumentState
The constructor argument state type used for aggregating constructor arguments.
VisitDictionary<TDictionary, TKey, TValue>(IDictionaryTypeShape<TDictionary, TKey, TValue>, object?)
Visits an IDictionaryTypeShape<TDictionary, TKey, TValue> instance representing a dictionary type.
public virtual object? VisitDictionary<TDictionary, TKey, TValue>(IDictionaryTypeShape<TDictionary, TKey, TValue> dictionaryShape, object? state = null) where TKey : notnull
Parameters
dictionaryShape
IDictionaryTypeShape<TDictionary, TKey, TValue>The dictionary shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TDictionary
The type of the visited dictionary.
TKey
The key type of the visited dictionary.
TValue
The value type of the visited dictionary.
VisitEnum<TEnum, TUnderlying>(IEnumTypeShape<TEnum, TUnderlying>, object?)
Visits an IEnumTypeShape<TEnum, TUnderlying> instance.
public virtual object? VisitEnum<TEnum, TUnderlying>(IEnumTypeShape<TEnum, TUnderlying> enumShape, object? state = null) where TEnum : struct, Enum
Parameters
enumShape
IEnumTypeShape<TEnum, TUnderlying>The enum shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TEnum
The type of visited enum.
TUnderlying
The underlying type used by the enum.
VisitEnumerable<TEnumerable, TElement>(IEnumerableTypeShape<TEnumerable, TElement>, object?)
Visits an IEnumerableTypeShape<TEnumerable, TElement> instance representing an enumerable type.
public virtual object? VisitEnumerable<TEnumerable, TElement>(IEnumerableTypeShape<TEnumerable, TElement> enumerableShape, object? state = null)
Parameters
enumerableShape
IEnumerableTypeShape<TEnumerable, TElement>The enumerable shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TEnumerable
The type of the visited enumerable.
TElement
The element type of the visited enumerable.
VisitObject<T>(IObjectTypeShape<T>, object?)
Visits an IObjectTypeShape<T> representing a simple type or object.
public virtual object? VisitObject<T>(IObjectTypeShape<T> objectShape, object? state = null)
Parameters
objectShape
IObjectTypeShape<T>The type shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
T
The object type represented by the shape instance.
VisitOptional<TOptional, TElement>(IOptionalTypeShape<TOptional, TElement>, object?)
Visits an IOptionalTypeShape<TOptional, TElement> instance representing optional types.
public virtual object? VisitOptional<TOptional, TElement>(IOptionalTypeShape<TOptional, TElement> optionalShape, object? state = null)
Parameters
optionalShape
IOptionalTypeShape<TOptional, TElement>The optional shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TOptional
The optional type described by the shape.
TElement
The type of the value encapsulated by the option type.
VisitParameter<TArgumentState, TParameterType>(IParameterShape<TArgumentState, TParameterType>, object?)
Visits an IParameterShape<TArgumentState, TParameterType> instance.
public virtual object? VisitParameter<TArgumentState, TParameterType>(IParameterShape<TArgumentState, TParameterType> parameterShape, object? state = null)
Parameters
parameterShape
IParameterShape<TArgumentState, TParameterType>The parameter shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TArgumentState
The constructor argument state type used for aggregating constructor arguments.
TParameterType
The type of the visited constructor parameter.
VisitProperty<TDeclaringType, TPropertyType>(IPropertyShape<TDeclaringType, TPropertyType>, object?)
Visits an IPropertyShape<TDeclaringType, TPropertyType> instance.
public virtual object? VisitProperty<TDeclaringType, TPropertyType>(IPropertyShape<TDeclaringType, TPropertyType> propertyShape, object? state = null)
Parameters
propertyShape
IPropertyShape<TDeclaringType, TPropertyType>The property shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TDeclaringType
The declaring type of the visited property.
TPropertyType
The property type of the visited property.
VisitSurrogate<T, TSurrogate>(ISurrogateTypeShape<T, TSurrogate>, object?)
Visits an ISurrogateTypeShape<T, TSurrogate> instance representing a type employing a surrogate type.
public virtual object? VisitSurrogate<T, TSurrogate>(ISurrogateTypeShape<T, TSurrogate> surrogateShape, object? state = null)
Parameters
surrogateShape
ISurrogateTypeShape<T, TSurrogate>The surrogate shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
T
The type represented by the shape instance.
TSurrogate
The surrogate type used by the shape.
VisitUnionCase<TUnionCase, TUnion>(IUnionCaseShape<TUnionCase, TUnion>, object?)
Visits an IUnionCaseShape<TUnionCase, TUnion> instance representing a union case.
public virtual object? VisitUnionCase<TUnionCase, TUnion>(IUnionCaseShape<TUnionCase, TUnion> unionCaseShape, object? state = null) where TUnionCase : TUnion
Parameters
unionCaseShape
IUnionCaseShape<TUnionCase, TUnion>The union case shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TUnionCase
The type of the visited union case.
TUnion
The type of the visited union.
VisitUnion<TUnion>(IUnionTypeShape<TUnion>, object?)
Visits an IUnionTypeShape<TUnion> instance representing a union type.
public virtual object? VisitUnion<TUnion>(IUnionTypeShape<TUnion> unionShape, object? state = null)
Parameters
unionShape
IUnionTypeShape<TUnion>The union shape to visit.
state
objectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TUnion
The type of the visited union.