ServiceFactory<T> typedef

ServiceFactory<T> = T Function(IServiceProvider provider)

Service Factory

T is the return type, which can be either a service type or a service implementation type.

Returns an instance of type T, and the factory method receives an IServiceProvider as a parameter.

If the service is ServiceLifeTime.singleton, then IServiceProvider is the root service provider; If the service is ServiceLifeTime.scoped, then IServiceProvider is the service provider of the corresponding scope; If the service is ServiceLifeTime.transient, then IServiceProvider is the service provider of the corresponding scope;

Implementation

typedef ServiceFactory<T> = T Function(IServiceProvider provider);