Converter

RegisterKnownStructType

Registers a custom struct or complex nested type so the automapper can correctly deserialize it when using SaveTo<T>. Call before WithInput for each type that the mapper cannot resolve automatically.

Registers a custom struct or complex nested type so the automapper can correctly deserialize it when using SaveTo<T>. Call before WithInput for each type that the mapper cannot resolve automatically.

GPAL's automapper handles standard .NET primitive types, collections, and most common types automatically. When your target class contains nested custom structs or types the mapper cannot resolve on its own, RegisterKnownStructType tells it how to handle them. Multiple calls can be chained to register several types before the input is set. Registration is per-converter-instance - it does not persist across separate GPAL.Converter chains.

WARNING

RegisterKnownStructType must appear before WithInput in the fluent chain. Registering a type after the input is set may result in the type not being recognized during mapping.

Examples

GPAL Fluent: High-level fluent C# API

//Each RegisterKnownStructType call returns IAllowConverterInput, allowing you to chain multiple registrations before setting the input source. The registered types are available for the full lifetime of that converter chain.

// Order contains nested OrderLine and Address types var order = new Order(); GPAL.Converter .RegisterKnownStructType(typeof(OrderLine)) .RegisterKnownStructType(typeof(Address)) .WithInput(GPAL.FileFor("order.json")) .WithOutputType(DataFormat.CLASS) .SaveTo<Order>(ref order);