Like most mappers, Mapster can do its job in a number of different and convenient ways.
Let's start with the most basic usage, where a source object can be directly mapped to a destination object:
var destObject = sourceObject.Adapt<TDestination>();
Alternatively, we can instantiate a mapper by ourselves (or get it through Dependency Injection):
IAdapter adapter = new Adapter();var destObject = adapter.Adapt<TDestination>(sourceObject);
All achieve the same result using a static method:
var destObject = TypeAdapter.Adapt<TDestination>;
All mappings can be either configured on-the-fly--during the mapping itself--or globally, using the TypeAdapterConfig static class, which also features a fluent and readable syntax:
TypeAdapterConfig<TSource, ...