Add the possibility to explicitly map one enum value to another enum value.
enum CarBrand { Audi, Stellantis }
enum CarBrandDto { Audi, FiatChrysler }
// declaration
[Mapper]
public partial DtoMapper
{
[MapEnum(EnumMappingStrategy.ByName]
[MapEnumValue(CarBrand.Stellantis, CarBrandDto.FiatChrysler)]
public partial CarBrandDto ToDto(CarBrand brand);
}
// implementation
public partial DtoMapper
{
public partial CarBrandDto ToDto(CarBrand brand)
{
return source switch
{
CarBrand.Audi => CarBrandDto.Audi,
CarBrand.Stellantis => CarBrandDto.FiatChrysler,
_ => throw new ...
};
}
}
Add the possibility to explicitly map one enum value to another enum value.