Do DI Factories need their own scope? #4672
Replies: 2 comments 5 replies
-
I tried to look in the source code and bumped into this issue when trying to find |
Beta Was this translation helpful? Give feedback.
-
Because your code calls AddControllers, I presume you are using IMvcBuilder. Then:
Unless In contrast, |
Beta Was this translation helpful? Give feedback.
-
When creating a di factory that resolves instances from the service provider, do I need to create a new scope before resolving the instance or is the service provider provided already in a scope so that I don't risk resolving instances from the root?
For example, I want to register
JsonSerializerOptions
to 1) avoid making the mistake of creating more instances than necessary and 2) avoid having to register the converters that I already have registered inAddJsonOptions
. Should I then resolveIOptions<JsonOptions>
directly from the service provider or should I create a new scope first?Beta Was this translation helpful? Give feedback.
All reactions