AddShared<T>(Func<ServiceProvider<TService>, T>)
Adds a lazily-created shared service to the builder. Shared services are instantiated once and shared across all service provider instances in the same family.
Declaration
public void AddShared<T>(Func<ServiceProvider<TService>, T> func) where T : class, TServiceParameters
| Type | Name | Description |
|---|---|---|
| Func<ServiceProvider<TService>, T> | func | A factory function that creates the service instance when needed. |
Type Parameters
| Name | Description |
|---|---|
| T | The interface type under which the service will be registered. This should be the
service interface (e.g., |
AddShared(TService)
Adds a shared service instance to the builder. Shared services are shared across all service provider instances in the same family.
Declaration
public void AddShared(TService service)Parameters
| Type | Name | Description |
|---|---|---|
| TService | service | The service instance to add. |