Class IocLocator
Provides a locator for resolving services and managing dependency injection containers.
Inherited Members
Namespace: Innovt.Core.CrossCutting.Ioc
Assembly: Innovt.Core.dll
Syntax
public static class IocLocator
Remarks
This static class acts as a locator for resolving services and managing dependency injection containers. It provides methods for initializing the container, resolving services, adding modules, releasing resources, creating service scopes, and checking container configuration.
Methods
| Edit this page View SourceAddModule(IocModule)
Adds an IocModule to the container.
Declaration
public static void AddModule(IocModule module)
Parameters
Type | Name | Description |
---|---|---|
IocModule | module | The IocModule to be added to the container. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
AddModuleFromAssembly(Assembly)
Adds modules from the specified assembly
to the container.
Declaration
public static void AddModuleFromAssembly(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | The assembly containing modules to be added. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
CheckConfiguration()
Checks the configuration of the container.
Declaration
public static void CheckConfiguration()
CreateScope()
Creates and returns a new service scope.
Declaration
public static IServiceScope CreateScope()
Returns
Type | Description |
---|---|
IServiceScope | An IServiceScope representing the new service scope. |
Initialize(IContainer)
Initializes the locator with the specified main dependency injection container.
Declaration
public static void Initialize(IContainer mainContainer)
Parameters
Type | Name | Description |
---|---|---|
IContainer | mainContainer | The main IContainer to be used for service resolution. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
Release(object)
Releases the specified object and frees associated resources.
Declaration
public static void Release(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to release. |
Resolve(Type)
Resolves a service of the specified type
.
Declaration
public static object Resolve(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The Type of the service to resolve. |
Returns
Type | Description |
---|---|
object | The resolved service object. |
Resolve<TService>()
Resolves a service of type TService
.
Declaration
public static TService Resolve<TService>()
Returns
Type | Description |
---|---|
TService | The resolved service object. |
Type Parameters
Name | Description |
---|---|
TService | The type of service to resolve. |
Resolve<TService>(string)
Resolves a named instance of a service of type TService
.
Declaration
public static TService Resolve<TService>(string intanceKey)
Parameters
Type | Name | Description |
---|---|---|
string | intanceKey | The key identifying the named instance to resolve. |
Returns
Type | Description |
---|---|
TService | The resolved service object. |
Type Parameters
Name | Description |
---|---|
TService | The type of service to resolve. |
Resolve<TService>(Type)
Resolves a service of type TService
with the specified type
.
Declaration
public static TService Resolve<TService>(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The Type of the service implementation to resolve. |
Returns
Type | Description |
---|---|
TService | The resolved service object. |
Type Parameters
Name | Description |
---|---|
TService | The type of service to resolve. |