Interface IContainer
Represents an interface for a dependency injection container.
Inherited Members
Namespace: Innovt.Core.CrossCutting.Ioc
Assembly: Innovt.Core.dll
Syntax
public interface IContainer : IDisposable
Remarks
This interface defines a contract for a dependency injection container that provides methods for registering modules, resolving services, releasing resources, and creating service scopes. It also includes a method for checking container configuration.
Methods
| Edit this page View SourceAddModule(IocModule)
Adds an IocModule to the container.
Declaration
void AddModule(IocModule iocModule)
Parameters
Type | Name | Description |
---|---|---|
IocModule | iocModule | The IocModule to be added to the container. |
CheckConfiguration()
Checks the configuration of the container.
Declaration
void CheckConfiguration()
CreateScope()
Creates and returns a new service scope.
Declaration
IServiceScope CreateScope()
Returns
Type | Description |
---|---|
IServiceScope | An IServiceScope representing the new service scope. |
Release(object)
Releases the specified object and frees associated resources.
Declaration
void Release(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to release. |
Resolve(Type)
Resolves a service of the specified type
.
Declaration
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
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
TService Resolve<TService>(string instanceKey)
Parameters
Type | Name | Description |
---|---|---|
string | instanceKey | 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
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. |
TryToResolve<TService>()
Try to resolve a service. If the service is not registered, return null.
Declaration
TService TryToResolve<TService>()
Returns
Type | Description |
---|---|
TService |
Type Parameters
Name | Description |
---|---|
TService |
TryToResolve<TService>(Type)
This method will not throw an exception if the service is not registered. Return null instead.
Declaration
TService TryToResolve<TService>(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type that you want to get an instance |
Returns
Type | Description |
---|---|
TService | Null or an instance of your type |
Type Parameters
Name | Description |
---|---|
TService |