Interaction Service uses dependency injection to perform most of its operations. This way, you can access service dependencies throughout the framework.
Microsoft.Extensions.DependencyInjection.ServiceCollection
.IServiceProvider
using the BuildServiceProvider()
method of the ServiceCollection
.IServiceProvider
to AddModulesAsync()
, AddModuleAsync()
and ExecuteAsync()
methods.Services of a IServiceProvider
can be accessed using Contructor Injection and Property Injection.
Interaction Service will populate the constructor parameters using the provided IServiceProvider
. Any public settable class Property will also be populated in the same manner.
Interaction Service has built-in support for scoped service types. Scoped lifetime services are instantiated once per command execution. Including the Preconditon checks, every module operation is executed within a single service scope (which is sepearate from the global service scope).
For more in-depth information about service lifetimes check out Microsoft Docs.