-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specific key with WithCtorParam #268
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 |
Thanks, that sounds like a good solution. Perhaps an exception should be thrown if you use the multi-type methods and then _.Export<Service>().WithCtorParam<ISubDependecy1, ISubDependency2, IDependency>((sd1, sd2) => new Dependency(sd1, sd2)).LocateWithKey("key") // Throws no error, but which dependency are we referring to?
.As<IService>(); I've got a separate key-related question so I'll just cheekily ask it here. I'm registering a dependency by key. In my controller I have that dependency in the constructor, without any |
Hmm that's tough the container isn't going to resolve that because you specifically registered the dependency with a key and the controller constructor has no way to decided which dependency to use. You should be able to put an |
I'm not a big fan of the |
Honestly I'm not a huge fan either but I also don't do keyed registration either. I think it could be an option to have a flag like that but I probably can't implement it any time soon. What if you exported a non keyed version that just looks up the keyed version you want? |
I suppose I could do that, yeah. Thanks for the tip! |
When using the
WithCtorParam
method with a single argument and in need to resolve a dependency with specific key, I know that you can useLocateWithKey
like this:But how do you solve this with multiple dependency arguments?
ISubDependecy1
andISubDependency2
are previously registered and with different keys.The text was updated successfully, but these errors were encountered: