Is it possible to share a user-implemented mapping method between mappers ? #1430
-
Hi, I'm in the same situation than this issue : #1107 Like in this issue I need to map gRPC timestamp. So I proceeded the same way explained in the issue : [Mapper]
public static partial class Mapper
{
public static partial GrpcResponse MapToGrpcResponse(this Response response);
private static Timestamp DateTimeOffsetToTimestamp(DateTimeOffset source)
{
return Timestamp.FromDateTimeOffset(source);
}
} But I don't have only one mapper that need this conversion. Is it possible to share the Regards, |
Beta Was this translation helpful? Give feedback.
Answered by
sveinhelge
Jul 31, 2024
Replies: 1 comment 2 replies
-
Are you looking for external mappings, see Mapperly docs [Mapper]
[UseStaticMapper(typeof(BananaMapper))]
public static partial class BoxMapper
{
public static partial BananaBox MapBananaBox(BananaBoxDto dto);
}
public static class BananaMapper
{
public static Banana MapBanana(BananaDto dto)
=> new Banana(dto.Weigth);
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
elendil-software
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are you looking for external mappings, see Mapperly docs