Class MappedTypes
- Namespace
- CStructSharp
- Assembly
- CStructSharp.dll
The registry of classes that implement ICStructMapped<TSelf>. Registration captures the type's static mapping members as delegates once, under the generic constraint, so the read and write paths can map an instance from its Type alone - no reflection, and therefore no trimming or Native AOT conventions. Generated mappers register themselves in a module initializer; a hand-written mapper does the same, or calls Register<T>() once at startup (registering twice is harmless).
public static class MappedTypes
- Inheritance
-
MappedTypes
- Inherited Members
Methods
ConvertValue<T>(object?, string)
Converts a value the reader produced (a pointer target, a union member) to T with the rules of Get<T>.
public static T ConvertValue<T>(object? value, string member)
Parameters
valueobjectThe value to convert.
memberstringThe member the value belongs to, for the failure message.
Returns
- T
The converted value.
Type Parameters
TThe destination type.
Exceptions
- CStructReadException
The value cannot be converted without loss.
IsMapped(Type)
Whether type was registered as a mapped class.
public static bool IsMapped(Type type)
Parameters
typeTypeThe type to look up.
Returns
MemberName(StructValue, string)
Finds the layout member a mapped property maps to, for a generated mapper that did not resolve its layout
at build time: the exact name, else the single case-insensitive match, else the single match after
underscores are ignored (bit_depth for BitDepth), else propertyName
itself (which the following Get reports as missing, with the members that exist).
public static string MemberName(StructValue source, string propertyName)
Parameters
sourceStructValueThe value being mapped.
propertyNamestringThe mapped property's name.
Returns
- string
The member name to read or write.
Register<T>()
Registers T so its instances can be read and written by type.
public static void Register<T>() where T : ICStructMapped<T>
Type Parameters
TA class implementing ICStructMapped<TSelf>.