Class ServiceProviderFactory.Builder
Represents builder of the service provider.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public sealed class ServiceProviderFactory.Builder : ISupplier<IServiceProvider>, IFunctional, IResettable
Constructors
View SourceBuilder()
Declaration
public Builder()
Methods
View SourceAdd<TService>(Func<TService>)
Registers the service factory of the specified type.
Declaration
public ServiceProviderFactory.Builder Add<TService>(Func<TService> factory) where TService : class
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TService> | factory | The service factory. |
Returns
| Type | Description |
|---|---|
| ServiceProviderFactory.Builder | This builder for subsequent calls. |
Type Parameters
| Name | Description |
|---|---|
| TService | The type of the service. |
Add<TService>(TService)
Registers the service of the specified type.
Declaration
public ServiceProviderFactory.Builder Add<TService>(TService service) where TService : notnull
Parameters
| Type | Name | Description |
|---|---|---|
| TService | service | The service instance. |
Returns
| Type | Description |
|---|---|
| ServiceProviderFactory.Builder | This builder for subsequent calls. |
Type Parameters
| Name | Description |
|---|---|
| TService | The type of the service. |
Remarks
This builder doesn't allow registration of multiple services of the same type.
Build(IServiceProvider?)
Constructs service provider.
Declaration
public IServiceProvider Build(IServiceProvider? fallback = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | fallback | The fallback provider used for service resolution. |
Returns
| Type | Description |
|---|---|
| IServiceProvider | The constructed service provider. |
Reset()
Clears internal state of this builder and makes it reusable for subsequent calls.
Declaration
public void Reset()