Interface ITypeShape
- Namespace
- PolyType.Abstractions
- Assembly
- PolyType.dll
Provides a strongly typed shape model for a given .NET type.
public interface ITypeShape
Properties
AttributeProvider
Gets the provider used for type-level attribute resolution.
ICustomAttributeProvider? AttributeProvider { get; }
Property Value
Kind
Gets determines the TypeShapeKind that the current shape supports.
TypeShapeKind Kind { get; }
Property Value
Provider
Gets the provider used to generate this instance.
ITypeShapeProvider Provider { get; }
Property Value
Type
Gets the underlying Type that this instance represents.
Type Type { get; }
Property Value
Methods
Accept(TypeShapeVisitor, object?)
Accepts an TypeShapeVisitor for strongly-typed traversal.
object? Accept(TypeShapeVisitor visitor, object? state = null)
Parameters
visitor
TypeShapeVisitorThe visitor to accept.
state
objectThe state parameter to pass to the underlying visitor.
Returns
GetAssociatedTypeFactory(Type)
Gets the factory for a type associated to this property's declared Type, as captured in AssociatedTypes or AssociatedTypes.
Func<object>? GetAssociatedTypeFactory(Type associatedType)
Parameters
associatedType
TypeThe associated type (which must be one found in the AssociatedTypes property). If the associated type is a generic type definition, the type arguments used on this shape's Type will be used to close the associated generic type.
Returns
- Func<object>
A factory for the associated type, or null if no factory for the associated type is available.
Remarks
ReflectionTypeShapeProvider can produce the factory on demand without any AssociatedTypes, while SourceGenTypeShapeProvider is expected to only produce the factory that was explicitly requested via attribute.
Exceptions
- InvalidOperationException
Thrown when this method is called on an instance that does not represent a generic type.
Invoke(ITypeShapeFunc, object?)
Invokes the specified generic function with the given state.
object? Invoke(ITypeShapeFunc func, object? state = null)
Parameters
func
ITypeShapeFuncThe generic function to be invoked.
state
objectThe state to be passed to the function.
Returns
- object
The result produced by the function.