-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Registering two named types with same name does not override first type #224
Comments
@rchamorro I'm not going to tackle this in 4.1 because we need to talk about how this should actually work. The "makeNamesUnique()" step is important for other reasons. Are these really different registrations with the same name? Do you control the order in which they're registered? You could simply add an extension method that would replace a named instance or remove a named instance. There's a workaround for what you need to do that doesn't involve code changes, so I'm going to leave this out for now. |
There are no different registrations with the same name but the same registry is included in other registries multiple times just to make sure that they have all the required dependencies. |
@rchamorro Sorry, catching up on Lamar for the first time in forever. In the case you're describing, it wouldn't be hard to just remove the prior registrations or to use an |
Having the same problem. Shouldn't this behave just like normal registrations where the last registered service is considered default? For<IService>.Use<Service1>()
For<IService>.Use<Service2>()
// --> Service2 used as default
For<IService>.Use<Service1>().Named("SomeService")
For<IService>.Use<Service2>().Named("SomeService")
// --> Service2 used as default This would at least be better than just assigning the service some "random" name especially since this is not documented. |
When registering two named instances with the same name, or the same registry is registered multiple times, Lamar is not able to find the named instance.
It throws this exception:
I would expect that if the name matches, the type is overriden by the last registered. Instead it creates two named instances "A1" and "A2"
This is the test I used:
I found the "problem" because I have a complex solution where I try to have a registry for each project and include the registry when there are dependencies between them. That makes that some registries are included multiple times.
The text was updated successfully, but these errors were encountered: