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
Full methods are virtual, and will throw NotImplementedException if not overridden.
Methods
VisitConstructor<TDeclaringType, TArgumentState>(IConstructorShape<TDeclaringType, TArgumentState>, object?)
Visits an IConstructorShape<TDeclaringType, TArgumentState> instance.
public virtual object? VisitConstructor<TDeclaringType, TArgumentState>(IConstructorShape<TDeclaringType, TArgumentState> constructorShape, object? state = null) where TArgumentState : IArgumentState
Parameters
constructorShapeIConstructorShape<TDeclaringType, TArgumentState>The constructor shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TDeclaringTypeThe declaring type of the visited constructor.
TArgumentStateThe 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
dictionaryShapeIDictionaryTypeShape<TDictionary, TKey, TValue>The dictionary shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TDictionaryThe type of the visited dictionary.
TKeyThe key type of the visited dictionary.
TValueThe 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 where TUnderlying : unmanaged
Parameters
enumShapeIEnumTypeShape<TEnum, TUnderlying>The enum shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TEnumThe type of visited enum.
TUnderlyingThe 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
enumerableShapeIEnumerableTypeShape<TEnumerable, TElement>The enumerable shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TEnumerableThe type of the visited enumerable.
TElementThe element type of the visited enumerable.
VisitEvent<TDeclaringType, TEventHandler>(IEventShape<TDeclaringType, TEventHandler>, object?)
Visits an IEventShape<TDeclaringType, TEventHandler> instance representing an event.
public virtual object? VisitEvent<TDeclaringType, TEventHandler>(IEventShape<TDeclaringType, TEventHandler> eventShape, object? state = null)
Parameters
eventShapeIEventShape<TDeclaringType, TEventHandler>The event shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TDeclaringTypeThe declaring type of the visited event.
TEventHandlerThe event handler type of the visited event.
VisitFunction<TFunction, TArgumentState, TResult>(IFunctionTypeShape<TFunction, TArgumentState, TResult>, object?)
Visits an IFunctionTypeShape<TFunction, TArgumentState, TResult> instance representing a function type.
public virtual object? VisitFunction<TFunction, TArgumentState, TResult>(IFunctionTypeShape<TFunction, TArgumentState, TResult> functionShape, object? state = null) where TArgumentState : IArgumentState
Parameters
functionShapeIFunctionTypeShape<TFunction, TArgumentState, TResult>The function shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TFunctionThe type of the function.
TArgumentStateThe function argument state type used for aggregating function arguments.
TResultThe return type of the visited function.
VisitMethod<TDeclaringType, TArgumentState, TResult>(IMethodShape<TDeclaringType, TArgumentState, TResult>, object?)
Visits an IMethodShape<TDeclaringType, TArgumentState, TResult> instance.
public virtual object? VisitMethod<TDeclaringType, TArgumentState, TResult>(IMethodShape<TDeclaringType, TArgumentState, TResult> methodShape, object? state = null) where TArgumentState : IArgumentState
Parameters
methodShapeIMethodShape<TDeclaringType, TArgumentState, TResult>The method shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TDeclaringTypeThe declaring type for the method.
TArgumentStateThe method argument state type used for aggregating method arguments.
TResultThe return type of the visited method.
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
objectShapeIObjectTypeShape<T>The type shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TThe 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
optionalShapeIOptionalTypeShape<TOptional, TElement>The optional shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TOptionalThe optional type described by the shape.
TElementThe 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) where TArgumentState : IArgumentState
Parameters
parameterShapeIParameterShape<TArgumentState, TParameterType>The parameter shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TArgumentStateThe constructor argument state type used for aggregating constructor arguments.
TParameterTypeThe 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
propertyShapeIPropertyShape<TDeclaringType, TPropertyType>The property shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TDeclaringTypeThe declaring type of the visited property.
TPropertyTypeThe 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
surrogateShapeISurrogateTypeShape<T, TSurrogate>The surrogate shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TThe type represented by the shape instance.
TSurrogateThe 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)
Parameters
unionCaseShapeIUnionCaseShape<TUnionCase, TUnion>The union case shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TUnionCaseThe type of the visited union case.
TUnionThe 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
unionShapeIUnionTypeShape<TUnion>The union shape to visit.
stateobjectDefines user-provided state.
Returns
- object
The result produced by the visitor.
Type Parameters
TUnionThe type of the visited union.