Class KnownSubTypeMapping<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 KnownSubTypeMapping<TBase>
Type Parameters
TBase
The base type or interface that all sub-types derive from or implement.
- Inheritance
-
KnownSubTypeMapping<TBase>
- Inherited Members
Methods
Add<TDerived>(int)
Adds a known sub-type to the mapping.
public void Add<TDerived>(int alias) where TDerived : TBase, IShapeable<TDerived>
Parameters
alias
intThe alias for the sub-type.
Type Parameters
TDerived
The sub-type.
Exceptions
- ArgumentException
Thrown when
alias
or the Type described bytypeShape
have already been added to this mapping.
Add<TDerived>(int, ITypeShape<TDerived>)
Adds a known sub-type to the mapping.
public void Add<TDerived>(int alias, ITypeShape<TDerived> typeShape) where TDerived : TBase
Parameters
alias
intThe alias for the sub-type.
typeShape
ITypeShape<TDerived>The shape of the sub-type.
Type Parameters
TDerived
The sub-type.
Exceptions
- ArgumentException
Thrown when
alias
or the Type described bytypeShape
have already been added to this mapping.
Add<TDerived>(int, ITypeShapeProvider)
Adds a known sub-type to the mapping.
public void Add<TDerived>(int alias, ITypeShapeProvider provider) where TDerived : TBase
Parameters
alias
int- The alias for the sub-type.
provider
ITypeShapeProvider-
The shape provider of
T
. This will typically be obtained by calling theShapeProvider
static property on a witness class (a class on which GenerateShapeAttribute<T> has been applied).
Type Parameters
TDerived
Exceptions
- ArgumentException
Thrown when
alias
or the Type described bytypeShape
have already been added to this mapping.
Add<TDerived, TProvider>(int)
Adds a known sub-type to the mapping.
public void Add<TDerived, TProvider>(int alias) where TDerived : TBase where TProvider : IShapeable<TDerived>
Parameters
alias
int- The alias for the sub-type.
Type Parameters
TDerived
The sub-type. TProvider
The witness class that provides a type shape for
TDerived
.
Exceptions
- ArgumentException
Thrown when
alias
or the Type described bytypeShape
have already been added to this mapping.