Class Container
A dependency injection container.
Implements
Inherited Members
Namespace: Evergine.Framework
Assembly: Evergine.Framework.dll
Syntax
public class Container : IDisposable
Constructors
Container()
Initializes a new instance of the Container class.
Declaration
public Container()
Methods
Dispose()
Declaration
public void Dispose()
IsRegistered(Type)
Returns true if type
is registered in container OR its open generic
definition is registered in container.
Declaration
public bool IsRegistered(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to be ckeck. |
Returns
Type | Description |
---|---|
bool |
|
IsRegistered<T>()
Returns true if T
is registered in container OR its open generic
definition is registered in container.
Declaration
public bool IsRegistered<T>()
Returns
Type | Description |
---|---|
bool |
|
Type Parameters
Name | Description |
---|---|
T | The type to be check. |
Register(Type, bool)
Registers the type type
for all implemented internal interfaces and base classes.
Declaration
public void Register(Type type, bool singleton = true)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to be registered. |
bool | singleton | Indicates is this types must be registered as singleton. |
Register(Type, Type, bool)
Registers a type
type implemented by implementationType
type.
Declaration
public void Register(Type type, Type implementationType, bool singleton = true)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to be registered. |
Type | implementationType | The implementation type to be registered. |
bool | singleton | Indicates is this types must be registered as singleton. |
RegisterInstance<TImplementation>(TImplementation)
Stores the externally created instance into singleton.
Declaration
public void RegisterInstance<TImplementation>(TImplementation instance)
Parameters
Type | Name | Description |
---|---|---|
TImplementation | instance | The externally created instance. |
Type Parameters
Name | Description |
---|---|
TImplementation | The implementation type to be registered. |
RegisterInterceptor(ContainerInterceptor)
Register a container interceptor.
Declaration
public void RegisterInterceptor(ContainerInterceptor containerInterceptor)
Parameters
Type | Name | Description |
---|---|---|
ContainerInterceptor | containerInterceptor | The container interceptor. |
RegisterType<TImplementation>(bool)
Registers implementation type TImplementation
for all implemented internal interfaces and base classes.
Declaration
public void RegisterType<TImplementation>(bool singleton = true)
Parameters
Type | Name | Description |
---|---|---|
bool | singleton | Indicates is this types must be registered as singleton. |
Type Parameters
Name | Description |
---|---|
TImplementation | The implementation type to be registered. |
RegisterType<T, TImplementation>(bool)
Registers a T
type implemented by TImplementation
type.
Declaration
public void RegisterType<T, TImplementation>(bool singleton = true) where TImplementation : T
Parameters
Type | Name | Description |
---|---|---|
bool | singleton | Indicates is this types must be registered as singleton. |
Type Parameters
Name | Description |
---|---|
T | The type to be registered. |
TImplementation | The implementation type to be registered. |
Resolve(Type)
Resolves instance of type from container.
Declaration
public object Resolve(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to be resolved. |
Returns
Type | Description |
---|---|
object | An instance for the specified type. |
ResolveMany(Type)
Returns all registered instances of type from container.
Declaration
public IEnumerable<object> ResolveMany(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to be resolved. |
Returns
Type | Description |
---|---|
IEnumerable<object> | An enumerable collection containing all registered instances. |
ResolveMany<T>()
Returns all registered instances of type T
from container.
Declaration
public IEnumerable<T> ResolveMany<T>()
Returns
Type | Description |
---|---|
IEnumerable<T> | An enumerable collection containing all registered instances. |
Type Parameters
Name | Description |
---|---|
T | The type to be resolved. |
Resolve<T>()
Resolves instance of type T
from container.
Declaration
public T Resolve<T>()
Returns
Type | Description |
---|---|
T | An instance for the specified type. |
Type Parameters
Name | Description |
---|---|
T | The type to be resolved. |
Unregister(Type)
Removes specified registration from container.
Declaration
public void Unregister(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to be unregistered. |
Unregister<T>()
Removes specified registration from container.
Declaration
public void Unregister<T>()
Type Parameters
Name | Description |
---|---|
T | The type to be unregistered. |
Unregister<T>(T)
Removes specified registration from container.
Declaration
public void Unregister<T>(T instance)
Parameters
Type | Name | Description |
---|---|---|
T | instance | The intance to be unregistered. |
Type Parameters
Name | Description |
---|---|
T | The type to be unregistered. |