Class ServiceProviderContainerBuilder
- Assembly
- Mokkit.Containers.Microsoft.Extensions.DependencyInjection.dll
Represents a builder for creating Microsoft.Extensions.DependencyInjection-based dependency injection containers. This builder implements the multiphase initialization lifecycle and provides fluent configuration methods for service registration.
public class ServiceProviderContainerBuilder : IDependencyContainerBuilderInheritance
Implements
Inherited Members
Methods
TryGetCollection<TCollection>()
Attempts to retrieve a collection of the specified type from the builder. This method is used for accessing the service collection during the build process.
public TCollection? TryGetCollection<TCollection>() where TCollection : classReturns
- TCollection?
-
The service collection cast to the requested type, or
nullif the cast is not possible.
Type Parameters
TCollection-
The type of collection to retrieve. Must be a reference type.
UseInit(Func<IServiceCollection, Task>)
Configures an initialization function to be executed during the initialization phase. This method provides a fluent interface for setting up service registration and configuration.
public ServiceProviderContainerBuilder UseInit(Func<IServiceCollection, Task> fn)Parameters
fnFunc<IServiceCollection, Task>-
The function to execute during initialization.
Returns
- ServiceProviderContainerBuilder
-
The current Mokkit.Containers.Microsoft.Extensions.DependencyInjection.ServiceProviderContainerBuilder instance for method chaining.
UsePreBuild<TCollection>(Func<IServiceCollection, TCollection, Task>)
Configures a pre-build function that coordinates with other container builders during the pre-build phase. This method allows for cross-builder interaction and shared configuration.
public ServiceProviderContainerBuilder UsePreBuild<TCollection>(Func<IServiceCollection, TCollection, Task> fn) where TCollection : classParameters
fnFunc<IServiceCollection, TCollection, Task>-
The function to execute during pre-build, receiving both the service collection and another builder's collection.
Returns
- ServiceProviderContainerBuilder
-
The current Mokkit.Containers.Microsoft.Extensions.DependencyInjection.ServiceProviderContainerBuilder instance for method chaining.
Type Parameters
TCollection-
The type of collection to retrieve from other builders.
Exceptions
- ArgumentException
-
Thrown when no collection of the specified type is found among the builders.
UsePreInit(Func<IServiceCollection, Task>)
Configures a pre-initialization function to be executed during the pre-initialization phase. This method provides a fluent interface for setting up early service configuration.
public ServiceProviderContainerBuilder UsePreInit(Func<IServiceCollection, Task> fn)Parameters
fnFunc<IServiceCollection, Task>-
The function to execute during pre-initialization.
Returns
- ServiceProviderContainerBuilder
-
The current Mokkit.Containers.Microsoft.Extensions.DependencyInjection.ServiceProviderContainerBuilder instance for method chaining.