ServiceProvider

Wisej.Services.ServiceProvider

Namespace: Wisej.Services

Assembly: Wisej.Framework (3.1.0.0)

Manages services for Wisej.NET's DI implementation.

public class ServiceProvider : IServiceProvider

Methods

AddService<TService>(lifetime)

Registers a scoped service.

Parameter
Type
Description

TService

The service to add.

lifetime

Scope of the service. Default is Shared.

Throws:

AddService<TService, TImplementation>(lifetime)

Registers a scoped service.

Parameter
Type
Description

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

lifetime

Scope of the service. Default is Shared.

Throws:

AddService<TService>(implementationTypeName, lifetime)

Registers a scoped service.

Parameter
Type
Description

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.

lifetime

Scope of the service. Default is Shared.

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:

AddService<TService>(serviceImplementation, lifetime)

Registers a scoped service.

Parameter
Type
Description

TService

The service to add.

serviceImplementation

Implementation for the TService .

lifetime

Scope of the service. Default is Shared.

Throws:

AddService<TService>(implementationFactory, lifetime)

Registers a scoped service.

Parameter
Type
Description

TService

The type of the service to add.

implementationFactory

Method for creating the TService instance.

lifetime

Scope of the service. Default is Shared.

Throws:

GetService<T>()

Returns the requested service.

Parameter
Type
Description

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.

Parameter
Type
Description

serviceType

Type of the service to add.

Returns: Object. An instance of serviceType or null if the service is not found.

Throws:

Inject(target)

Injects the services into the properties marked with the InjectAttribute attributed on the specified target object.

Parameter
Type
Description

target

Target object to inject dependencies into.

Throws:

RemoveService(serviceType)

Removes the specified service type from the service container.

Parameter
Type
Description

serviceType

Type of the service to remove.

Throws:

Last updated