The effective lifetime depends on how IWorkService
is created / requested from the dependency injection container.
If there is, for example, a singleton CallerService
which gets a IWorkService
constructor-injected, that service will use the same IWorkService
for each call.
On the other hand, if the CallerService
uses an IServiceProvider
(for example via an IServiceScopeFactory
) - each time GetService
is used to get the IWorkService
- a new instance will be created.
If the CallerService
itself is transient-scoped, the question is shifted to who creates that service at which time.
To sum up, the word "request" describes the act of calling the service provider's GetService
method (directly or via some helper method). For each such call, a new instance will be created, if the desired service is transient-scoped.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…