dart_service_provider library

Lifecycle management and instance resolution of service objects.

Classes

Environment
Default IEnvironment implementation
Environments
Defines commonly used environment names.
IAsyncDisposable
Used to release resources asynchronously.
IConfigurable
Indicates that instances of this service can be configured by ServiceConfigure and ServicePostConfigure.
IDisposable
Indicates the interface for which resources need to be released.
IEnvironment
Environment interface
IServiceCollection
A service collection interface for configuring and adding services.
IServiceProvider
Service provider interface
IServiceProviderIsService
Used to detect whether a type is registered as a service.
IServiceScope
Service scope
IServiceScopeFactory
Service Scope Factory
LoggerOptions
Options for logger
LoggingBuilder
The class that help build logging services.
ServiceCollection
The default implementation of a collection of services.
ServiceConfigure<TService>
Configure the service when it's created.
ServiceDescriptor<TService, TImplementation extends TService>
Service Descriptor
ServicePostConfigure<TService>
Configure the service when it's created, but ServicePostConfigure runs after all ServiceConfigure.
ServiceProvider
Represents the root service provider

Enums

ServiceLifeTime
Service life-time

Extensions

ConfigureServiceCollectionExtensions on IServiceCollection
Provides extension methods for configuration of service instances.
CopyServiceDescriptorExtensions on ServiceDescriptor
Provides ServiceDescriptor copy method.
EditableServiceCollectionExtensions on IServiceCollection
Define the extension method for editing IServiceCollection.
EnumerableServiceCollectionExtensions on IServiceCollection
Define an extension method for adding enumerable services
EnvironmentExtensions on IEnvironment
Provide environment check
EnvironmentServiceCollectionExtensions on IServiceCollection
Environment service extension methods
LoggingBuilderExtensions on LoggingBuilder
Extensions that helps config logging services
LoggingServiceCollectionExtension on IServiceCollection
Provide logging service configuration methods
LoggingServiceProviderExtensions on IServiceProvider
ServiceCollectionExtensions on IServiceCollection
Define the build ServiceProvider and the extension method used to register the service
ServiceProviderExtensions on IServiceProvider
IServiceProvider extension to provide methods for service acquisition and scope creation

Typedefs

ConfigureAction<TService> = void Function(IServiceProvider p, TService service)
Service configure action
Decorator = ServiceDescriptor Function(ServiceDescriptor descriptor)
Decorator for the service descriptor
ServiceFactory<T> = T Function(IServiceProvider provider)
Service Factory

Exceptions / Errors

InvalidScopeError
Indicates an error that gets a scoped service in the root scope.
ObjectDisposedError
Error that the object has been released and can no longer be used.
ServiceNotFoundError
Indicates an error that service was not found.