-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Multiple nested scope registrations #2351
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
Comments
From @Eilon on Friday, January 22, 2016 5:27:13 PM Moving this to Backlog as we are not planning to make any changes for this at this time. |
From @dazinator on Thursday, July 13, 2017 10:57:56 AM I am looking at how to achieve the following. As well as an |
From @dazinator on Thursday, July 13, 2017 11:04:09 AM It would be really good if I could register some sort of generic delegate into the child container to be invoked as a fallback for whenever a service wasn't registered - in there I could defer resolution to an alternate IServiceProvider (i.e the parent one).. Is this possible? |
For example AutoFac has this implemented.
|
Can we agree that this issue is closely related to #2355 ? |
We have no plans to add support to child containers. We recommend you use a 3rd party container for this (like autofac) |
Yeah, too hard probably. I tried to create a pull-request for this, but it seems like we would need to refactor a very large part in order to allow this. |
From @ghost on Friday, November 13, 2015 3:18:13 PM
When doing multiple nested scopes through
IServiceScopeFactory.CreateScope()
, you get nestedIServiceProvider
instances. It doesn't, however, give access to registrations for each scope.Therefore if you have scopes which are created further down the pipeline (with some service data only accessible from that step in the pipeline, which isn't available at the root), you can't really register services to use in there.
The sought-after structure being:
Scope (root)
- Register (root)
- Resolve (root level)
<- Scope (level 1)
- Register (level 1)
- Resolve (root level + level 1)
<- Scope (level 2)
- Register (level 2)
- Resolve (root level + level 1 + level 2)
I don't know if there's an alternative way of achieving this, but so far the documentation is scarce.
Copied from original issue: aspnet/DependencyInjection#327
The text was updated successfully, but these errors were encountered: