You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chaowlert edited this page Apr 13, 2019
·
3 revisions
Custom type conversion
In some cases, you may want to have complete control over how an object is mapped. You can register specific transformations using the MapWith method.
//Example of transforming string to char[].TypeAdapterConfig<string,char[]>.NewConfig().MapWith(str =>str.ToCharArray());
MapWith also useful if you would like to copy instance rather than deep copy the object, for instance, JObject or DbGeography, these should treat as primitive types rather than POCO.
In case you would like to combine MapWith with other settings, for example, PreserveReference, Include, or AfterMapping, you can pass applySettings to true.
NOTE: if you set MapWith setting but no MapToTargetWith setting, Mapster will use logic from MapWith setting.
Custom actions after mapping
You might not need to specify custom mapping logic completely. You can let Mapster do the mapping, and you do logic where Mapster cannot cover by using AfterMapping.