Mapster
Mapster copied to clipboard
Add - Inherits Lazy
add Setting:
.InheritsLazy<,>()
Lazy loads settings for inherited types during the first call to Adapt<>
Example:
TypeAdapterConfig<DerivedPoco, DerivedDto>.NewConfig()
.InheritsLazy<SimplePoco, SimpleDto>()
.Compile();
TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig()
.InheritsLazy<RootPoco, RootDto>()
.Ignore(dest => dest.Name)
.Compile();
TypeAdapterConfig<RootPoco, RootDto>.NewConfig()
.Map(dest => dest.NumberDto, src => 42)
.Compile();
dto = TypeAdapter.Adapt<DerivedDto>(source);
dto.Id.ShouldBe(source.Id);
dto.Name.ShouldBeNull(); // InheritsLazy Ignore is work
dto.NumberDto.ShouldBe(42); // InheritsLazy is work