SimpleServiceProvider class¶
A minimal IServiceProvider implementation with no dependency on any DI container. Intended for applications and tests that do not need a full container. Applications with a container register the services their own way, see RegisterApplicationServices.
Public Members¶
| name | description |
|---|---|
| SimpleServiceProvider() | The default constructor. |
| AddSingleton(…) | Registers a service factory. The instance is created on first request. The signature is compatible with RegisterApplicationServices: ApplicationServicesContext.RegisterApplicationServices(provider.AddSingleton); |
| AddSingleton<TService>(…) | Registers a ready instance under the TService type. The type is stated explicitly so a service cannot be accidentally registered under its concrete class instead of its interface. |
| Dispose() | Disposes the created services that implement IDisposable. |
| GetService(…) |
Remarks¶
All services are created lazily and live as singletons. Created instances implementing IDisposable are disposed by Dispose.