ServiceProvider
Wisej.Services.ServiceProvider
Namespace: Wisej.Services
Assembly: Wisej.Framework (4.0.0.0)
Manages services for Wisej.NET's DI implementation.
public class ServiceProvider : IServiceProvider
Methods
AddOrReplaceService<TService>(lifetime)

Registers or replaces a scoped service. Since 4.0.0
TService
The service to add.
Returns: ServiceProvider.
Throws:
InvalidOperationException A service of type TService is already registered.
AddOrReplaceService(serviceType, lifetime)

Registers or replaces a scoped service. Since 4.0.0
Returns: ServiceProvider.
This non-generic method supports the registration of generic services:

Registers or replaces a scoped service. Since 4.0.0
TService
The type of the service to add.
TImplementation
The type of the implementation to use.
Returns: ServiceProvider.
Throws:
InvalidOperationException A service of type TService is already registered.
AddOrReplaceService(serviceType, implementationType, lifetime)

Registers a scoped service. Since 4.0.0
Returns: ServiceProvider.
This non-generic method supports the registration of generic services:

Registers or replaces a scoped service. Since 4.0.0
TService
The type of the service to add.
implementationTypeName
The name of the type of the implementation; can be a fully qualified assembly + type name.
Returns: ServiceProvider.
Using this overload allows the application to register a service implementation that is loaded dynamically when requested. If implementationTypeName is a fully qualified type name, including the assembly name, the assembly and type are loaded on demand. Throws:
ArgumentNullException implementationTypeName is null or empty.
InvalidOperationException A service of type TService is already registered.
AddOrReplaceService(serviceType, implementationTypeName, lifetime)

Registers or replaces a scoped service. Since 4.0.0
implementationTypeName
The name of the type of the implementation; can be a fully qualified assembly + type name.
Returns: ServiceProvider.
Using this overload allows the application to register a service implementation that is loaded dynamically when requested. If implementationTypeName is a fully qualified type name, including the assembly name, the assembly and type are loaded on demand. This non-generic method supports the registration of generic services:

Registers or replaces a scoped service. Since 4.0.0
TService
The service to add.
Returns: ServiceProvider.
Throws:
ArgumentNullException serviceImplementation is null.
InvalidCastException serviceImplementation cannot be assigned to TService .
InvalidOperationException A service of type TService is already registered.
AddOrReplaceService(serviceType, serviceImplementation, lifetime)

Registers or replaces a scoped service. Since 4.0.0
Returns: ServiceProvider.
This non-generic method supports the registration of generic services:

Registers or replaces a scoped service. Since 4.0.0
TService
The type of the service to add.
Returns: ServiceProvider.
Throws:
NullReferenceException implementationFactory is null.
InvalidOperationException A service of type TService is already registered.
AddOrReplaceService(serviceType, implementationFactory, lifetime)

Registers or replaces a scoped service. Since 4.0.0
Returns: ServiceProvider.
This non-generic method supports the registration of generic services:

Registers a scoped service.
TService
The service to add.
Returns: ServiceProvider.
Throws:
InvalidOperationException A service of type TService is already registered.
AddService(serviceType, lifetime)

Registers a scoped service. Since 3.5.4
Returns: ServiceProvider.
This non-generic method supports the registration of generic services:

Registers a scoped service.
TService
The type of the service to add.
TImplementation
The type of the implementation to use.
Returns: ServiceProvider.
Throws:
InvalidOperationException A service of type TService is already registered.
AddService(serviceType, implementationType, lifetime)

Registers a scoped service. Since 3.5.4
Returns: ServiceProvider.
This non-generic method supports the registration of generic services:

Registers a scoped service.
TService
The type of the service to add.
implementationTypeName
The name of the type of the implementation; can be a fully qualified assembly + type name.
Returns: ServiceProvider.
Using this overload allows the application to register a service implementation that is loaded dynamically when requested. If implementationTypeName is a fully qualified type name, including the assembly name, the assembly and type are loaded on demand. Throws:
ArgumentNullException implementationTypeName is null or empty.
InvalidOperationException A service of type TService is already registered.
AddService(serviceType, implementationTypeName, lifetime)

Registers a scoped service. Since 3.5.4
implementationTypeName
The name of the type of the implementation; can be a fully qualified assembly + type name.
Returns: ServiceProvider.
Using this overload allows the application to register a service implementation that is loaded dynamically when requested. If implementationTypeName is a fully qualified type name, including the assembly name, the assembly and type are loaded on demand. This non-generic method supports the registration of generic services:

Registers a scoped service.
TService
The service to add.
Returns: ServiceProvider.
Throws:
ArgumentNullException serviceImplementation is null.
InvalidCastException serviceImplementation cannot be assigned to TService .
InvalidOperationException A service of type TService is already registered.
AddService(serviceType, serviceImplementation, lifetime)

Registers a scoped service. Since 3.5.4
Returns: ServiceProvider.
This non-generic method supports the registration of generic services:

Registers a scoped service.
TService
The type of the service to add.
Returns: ServiceProvider.
Throws:
NullReferenceException implementationFactory is null.
InvalidOperationException A service of type TService is already registered.
AddService(serviceType, implementationFactory, lifetime)

Registers a scoped service. Since 3.5.4
Returns: ServiceProvider.
This non-generic method supports the registration of generic services:

Returns the requested service.
T
Type of the service to retrieve.
Returns: T. An instance of T or null if the service is not found.
GetService(serviceType)

Returns the requested service.
Returns: Object. An instance of serviceType or null if the service is not found.
Throws:
ArgumentNullException serviceType is null.
HasService<T>()

Checks if a service of type T is already registered. Since 3.5.12
T
Service type to check.
Returns: Boolean. true if the service is registered.
HasService(serviceType)

Checks if a service of type serviceType is already registered. Since 3.5.12
Returns: Boolean. true if the service is registered.
Inject(target)

Injects the services into the properties marked with the InjectAttribute attributed on the specified target object.
Throws:
ArgumentNullException target is null.
RemoveService<TService>()

Removes the specified service type from the service container.
TService
The service to remove.
Returns: ServiceProvider.
RemoveService(serviceType)

Removes the specified service type from the service container.
Returns: ServiceProvider.
Throws:
ArgumentNullException serviceType is null.
Last updated
Was this helpful?