-
-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add generic counterparts for TryResolveNamed, TryResolveKeyed and TryResolveService #1263
Comments
I can offer to prepare a pull-request with the changes I described above. Right now, it seems like there are no specific tests for many of the extension methods in |
If that's a valid use case and you feel like sending a PR our way that would be great. My feeling is that whenever there is something new added, adding tests for those specific bits makes sense. |
I actually got a little confused myself the other day by the absence of generic forms of As a related note, you can just about use I'm not sure of the benefit of |
Since there has been no activity here for a long period of time, I decided to work on it and I already have some progress. However, as mentioned above, is there any benefit of |
Thanks for picking this up @v0idzz. I think |
@lukoerfer , Do you have anything else to add? |
Problem Statement
The static class
ResolutionExtensions
provides a set of extension methods to manually resolve instances from a container. Some of these methods (e.g.Resolve
andTryResolve
) have a generic counterpart (Resolve<T>
andTryResolve<T>
), but others, namelyTryResolveNamed
,TryResolveKeyed
andTryResolveService
, dont.Desired Solution
The generic counterparts could just call the non-generic extension methods and then cast the
out
parameter in the same way as the generic versionTryResolve
.Alternatives You've Considered
Right know, one can either write their own extension methods or use other workarounds (e.g. resolve
IIndex<string, T>
and useTryGetValue
as an alternative toTryResolveNamed
).Additional Context
None
The text was updated successfully, but these errors were encountered: