Class TypeShapeResolver
- Namespace
- PolyType.Abstractions
- Assembly
- PolyType.dll
Defines helpers methods used for resolving ITypeShape instances from source generated types.
public static class TypeShapeResolver
- Inheritance
-
TypeShapeResolver
- Inherited Members
Methods
ResolveDynamicOrThrow<T>()
Uses reflection to resolve the source generated ITypeShape<T> implementation of the type.
public static ITypeShape<T> ResolveDynamicOrThrow<T>()
Returns
- ITypeShape<T>
An ITypeShape<T> instance describing
T
.
Type Parameters
T
The type from which to extract the shape.
Remarks
Uses reflection to look for potential IShapeable<T> implementations or
TypeShapeProviderAttribute annotations inserted onto T
by the source generator.
Intended for compatibility with older frameworks where the IShapeable<T> interface (which uses static abstract interface methods) is not available.
Exceptions
- NotSupportedException
No source generated shape could be resolved.
ResolveDynamicOrThrow<T, TProvider>()
Uses reflection to resolve the source generated ITypeShape<T> implementation from another type.
public static ITypeShape<T> ResolveDynamicOrThrow<T, TProvider>()
Returns
- ITypeShape<T>
An ITypeShape<T> instance describing
T
.
Type Parameters
T
The type for which to extract the shape.
TProvider
The type from which to extract the shape.
Remarks
Uses reflection to look for potential IShapeable<T> implementations or
TypeShapeProviderAttribute annotations inserted onto T
by the source generator.
Intended for compatibility with older frameworks where the IShapeable<T> interface (which uses static abstract interface methods) is not available.
Exceptions
- NotSupportedException
No source generated shape could be resolved.
ResolveDynamic<T>()
Uses reflection to resolve the source generated ITypeShape<T> implementation of the type.
public static ITypeShape<T>? ResolveDynamic<T>()
Returns
- ITypeShape<T>
An ITypeShape<T> instance describing
T
, or null if none is found.
Type Parameters
T
The type from which to extract the shape.
Remarks
Uses reflection to look for potential IShapeable<T> implementations or
TypeShapeProviderAttribute annotations inserted onto T
by the source generator.
Intended for compatibility with older frameworks where the IShapeable<T> interface (which uses static abstract interface methods) is not available.
ResolveDynamic<T, TProvider>()
Uses reflection to resolve the source generated ITypeShape<T> implementation from another type.
public static ITypeShape<T>? ResolveDynamic<T, TProvider>()
Returns
- ITypeShape<T>
An ITypeShape<T> instance describing
T
, or null if none is found.
Type Parameters
T
The type for which to extract the shape.
TProvider
The type from which to extract the shape.
Remarks
Uses reflection to look for potential IShapeable<T> implementations or
TypeShapeProviderAttribute annotations inserted onto T
by the source generator.
Intended for compatibility with older frameworks where the IShapeable<T> interface (which uses static abstract interface methods) is not available.
Resolve<T>()
Resolves the ITypeShape<T> from the IShapeable<T> implementation of the type.
public static ITypeShape<T> Resolve<T>() where T : IShapeable<T>
Returns
- ITypeShape<T>
An ITypeShape<T> instance describing
T
.
Type Parameters
T
The type from which to extract the shape.
Resolve<T, TProvider>()
Resolves the ITypeShape<T> from the IShapeable<T> implementation of another type.
public static ITypeShape<T> Resolve<T, TProvider>() where TProvider : IShapeable<T>
Returns
- ITypeShape<T>
An ITypeShape<T> instance describing
T
.
Type Parameters
T
The type for which to extract the shape.
TProvider
The type providing the IShapeable<T> implementation.