Specific key with WithCtorParam
See original GitHub issueWhen using the WithCtorParam
method with a single argument and in need to resolve a dependency with specific key, I know that you can use LocateWithKey
like this:
_.Export<Service>().WithCtorParam<IDependency>().LocateWithKey("key")
.As<IService>();
But how do you solve this with multiple dependency arguments?
_.Export<Service>().WithCtorParam<ISubDependecy1, ISubDependency2, IDependency>((sd1, sd2) => new Dependency(sd1, sd2))
.As<IService>();
ISubDependecy1
and ISubDependency2
are previously registered and with different keys.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Issues · ipjohnson/Grace
Specific key with WithCtorParam enhancement. #268 opened on Aug 9, 2020 by silkfire · 6 · Resolving delegate factories for multiple services of...
Read more >how to get values of specific key in javascript
with Object.values.fruits I get all the values, so I tried it with Object.values(fruits.apple) to specify the key
Read more >Grace
Grace is a feature-rich dependency injection container designed with ease of use and performance in mind. using Grace.DependencyInjection; var container = ...
Read more >C# (CSharp) IDependencyInjectionContainer Examples
C# (CSharp) IDependencyInjectionContainer - 58 examples found. These are the top rated real world C# (CSharp) examples of IDependencyInjectionContainer ...
Read more >Gradually change the return type of collection min/max ...
minWith(comparator: Comparator<in Char>): Char? fun Array<out Double>.min(): ... about property initialized with ctor param (vor 3 Tagen) <Sergey Igushkin> ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think at the moment there isn’t really a way to handle. This maybe a case where you have to hand wire this instance. I’ll look at what it would take to do something like
WithCtorParam<T>(Func<IExportLocatorScope,T> func)
where you can wire up the specific logic you need for wiring up the dependency,I suppose I could do that, yeah. Thanks for the tip!