C#C
C#3y ago
Anton

❔ Is something like this possible with the default DI package?

So what I want to do is like this

How scopes work normally:
  • global scope
    • scope 1
      • scoped service A
      • scoped service B
    • scope 2
      • scoped service A (different instance)
      • scoped service B (different instance)
What I want is to be able to resolve scoped services of the parent from a subscope, but create new services for some types in subscopes (are there even subscopes?)

  • global scope
    • scope 1
      • service A
      • scope 1.1
        • service A resolved to the one of the parent
        • service B
      • scope 1.2
        • different instance of service B
I've seen a lib allow this, but it's for Unity. They did it through custom scope classes.

Autofac might allow this too? I'm not sure.
Was this page helpful?