Use value resolvers directly from IMapper #3745
frankhaugen
started this conversation in
Ideas
Replies: 1 comment
-
Maybe that's a code smell. Perhaps you're using resolvers when you need some other extensibility point (type converters, value converters, etc). Or you simply need some code reuse between your resolvers, probably through DI. But I, for one, don't really see the need for such a feature. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have spent a lot of time writing resolvers over the last year, and I love them, but sometimes I'd love to use the resolution context to use another resolver, (I might have missed some docs that gives me exactly what I need so I apologize if that's the case).
So take this simple resolver as base example, which is just perfect for what it's doing
It's something that could be inlined in a
.ForMember()
, but it's cleaner and reusable across different profilesBut to use this, I need a profile aswell, and might even need a DTO in there to make the profile not be a mess.
What I would propose is something like this, (yes I know the source and destination variable have to be implemented differently):
And:
Then I can use it liberally in places that needs it. Yes I could have the resolver call on a static helper class, and have all the logic there, but that would defeat the purpose of a resolver, right?
I am not going to spend the time looking into making something like this and raise a PR if people really don't like it so please give feedback 😃
Beta Was this translation helpful? Give feedback.
All reactions