Wisej.Services.InjectAttribute
Namespace: Wisej.Services
Assembly: Wisej.Framework (3.1.0.0)
Indicates that the associated property references a service injected by the service provider during initialization.
Use this attribute on properties (can be private, protected, or public) that represent an injected service instance.
Dependency injection is applied automatically for all top level containers: Form, Page, Desktop; and for all service instances created by the system. You can also inject dependencies into other objects by calling Application.Services.Inject after creating the target object.
Initializes a new instance of the InjectAttribute class.
Initializes a new instance of the InjectAttribute class.
Boolean: Indicates that the service is required.
Name | Type | Description |
---|---|---|
required
True to indicated that the service is required.
Wisej.Services.ServiceProvider
Namespace: Wisej.Services
Assembly: Wisej.Framework (3.1.0.0)
Manages services for Wisej.NET's DI implementation.
Registers a scoped service.
Parameter | Type | Description |
---|---|---|
Throws:
InvalidOperationException A service of type TService is already registered.
Registers a scoped service.
Parameter | Type | Description |
---|---|---|
Throws:
InvalidOperationException A service of type TService is already registered.
Registers a scoped service.
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:
InvalidOperationException A service of type TService is already registered.
Registers a scoped service.
Throws:
ArgumentNullException serviceImplementation is null.
InvalidCastException serviceImplementation cannot be assigned to TService .
InvalidOperationException A service of type TService is already registered.
Registers a scoped service.
Throws:
NullReferenceException implementationFactory is null.
InvalidOperationException A service of type TService is already registered.
Returns the requested service.
Returns: T. An instance of T or null if the service is not found.
Returns the requested service.
Returns: Object. An instance of serviceType or null if the service is not found.
Throws:
ArgumentNullException serviceType is null.
Injects the services into the properties marked with the InjectAttribute attributed on the specified target object.
Throws:
ArgumentNullException target is null.
Removes the specified service type from the service container.
Throws:
ArgumentNullException serviceType is null.
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Session
A new instance of the service is created and cached for the current session; it will be automatically disposed, if it implements an IDisposable, at the end of the session.
Shared
A single static instance of the service is available to all sessions.
Thread
A new instance of the service is created for each new thread; it will be automatically disposed, if it implements an IDisposable, at the end of the request.
Transient
A new instance of the service is created every time it's requested. The consumer is responsible for disposing it.
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.
lifetime
Scope of the service. Default is Shared.
TService
The service to add.
serviceImplementation
Implementation for the TService .
lifetime
Scope of the service. Default is Shared.
TService
The type of the service to add.
implementationFactory
Method for creating the TService instance.
lifetime
Scope of the service. Default is Shared.
T
Type of the service to retrieve.
serviceType
Type of the service to add.
target
Target object to inject dependencies into.
serviceType
Type of the service to remove.
TService
The service to add.
lifetime
Scope of the service. Default is Shared.
TService
The type of the service to add.
TImplementation
The type of the implementation to use.
lifetime
Scope of the service. Default is Shared.