Class DerivedTypeMapping<TBase>
- Namespace
- Nerdbank.MessagePack
- Assembly
- Nerdbank.MessagePack.dll
Describes a mapping between a base type and its known sub-types, along with the aliases that identify them.
public class DerivedTypeMapping<TBase> : DerivedShapeMapping<TBase>, IEnumerable<KeyValuePair<DerivedTypeIdentifier, ITypeShape>>, IEnumerable
Type Parameters
TBase
The base type or interface that all sub-types derive from or implement.
- Inheritance
-
DerivedShapeMapping<TBase>DerivedTypeMapping<TBase>
- Implements
- Inherited Members
Constructors
DerivedTypeMapping(ITypeShapeProvider)
Describes a mapping between a base type and its known sub-types, along with the aliases that identify them.
public DerivedTypeMapping(ITypeShapeProvider provider)
Parameters
provider
ITypeShapeProviderThe type shape provider to use for a type when added without an express shape or provider.
Properties
BaseType
Gets the base union type.
public override Type BaseType { get; }
Property Value
this[DerivedTypeIdentifier]
Gets or sets a sub-type's Type by its alias.
public Type this[DerivedTypeIdentifier alias] { get; set; }
Parameters
alias
DerivedTypeIdentifierThe alias of the sub-type.
Property Value
Remarks
When adding a subtype via this indexer, the ITypeShape<T> for the value
will be obtained from the ITypeShapeProvider provided to the constructor.
Methods
Add(DerivedTypeIdentifier, Type)
Adds a known sub-type to the mapping.
public void Add(DerivedTypeIdentifier alias, Type type)
Parameters
alias
DerivedTypeIdentifierThe alias for the sub-type.
type
TypeThe Type of the sub-type.
Remarks
The ITypeShape<T> for the type
will be obtained from the ITypeShapeProvider provided to the constructor.