question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specific key with WithCtorParam

See original GitHub issue

When 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:open
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ipjohnsoncommented, Aug 11, 2020

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,

0reactions
silkfirecommented, Aug 13, 2020

I suppose I could do that, yeah. Thanks for the tip!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found