Class Container
Onbox's IOC container implementation
Inheritance
Inherited Members
Namespace: Onbox.Di.V8
Assembly: Onbox.Di.dll
Syntax
public class Container : IContainer, IContainerResolver, IDisposable
Fields
| Improve this Doc View SourcescopedInstances
The list of current scoped instances currently registered
Declaration
protected readonly IDictionary<Type, object> scopedInstances
Field Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Object> |
scopedTypes
The list of current scoped types currently registered
Declaration
protected IDictionary<Type, Type> scopedTypes
Field Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Type> |
singletonInstances
The list of current singleton instances currently registered
Declaration
protected IDictionary<Type, object> singletonInstances
Field Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Object> |
singletonTypes
The list of current singleton types currently registered
Declaration
protected IDictionary<Type, Type> singletonTypes
Field Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Type> |
transientTypes
The list of current transient types currently registered
Declaration
protected IDictionary<Type, Type> transientTypes
Field Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Type> |
Methods
| Improve this Doc View SourceAddScoped<TImplementation>()
Adds a scoped implementation on the container.
Declaration
public void AddScoped<TImplementation>()
where TImplementation : class
Type Parameters
Name | Description |
---|---|
TImplementation |
AddScoped<TContract, TImplementation>()
Adds a scoped implementation to a contract on the container.
Declaration
public void AddScoped<TContract, TImplementation>()
where TImplementation : class, TContract
Type Parameters
Name | Description |
---|---|
TContract | |
TImplementation |
AddSingleton<TImplementation>()
Adds an implementation as a singleton on the container.
Declaration
public void AddSingleton<TImplementation>()
where TImplementation : class
Type Parameters
Name | Description |
---|---|
TImplementation |
Remarks
It can not be an abstract or interface type
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when using a abstract class or an interface |
AddSingleton<TImplementation>(TImplementation)
Adds an instance as a singleton on the container
Declaration
public void AddSingleton<TImplementation>(TImplementation instance)
where TImplementation : class
Parameters
Type | Name | Description |
---|---|---|
TImplementation | instance |
Type Parameters
Name | Description |
---|---|
TImplementation |
AddSingleton<TContract, TImplementation>()
Adds an implementation to a contract as a singleton on the container
Declaration
public void AddSingleton<TContract, TImplementation>()
where TImplementation : class, TContract
Type Parameters
Name | Description |
---|---|
TContract | |
TImplementation |
Remarks
It can not be an abstract or interface type
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when using a abstract class or an interface |
AddSingleton<TContract, TImplementation>(TImplementation)
Adds an instance as a singleton on the container
Declaration
public void AddSingleton<TContract, TImplementation>(TImplementation instance)
where TImplementation : TContract
Parameters
Type | Name | Description |
---|---|---|
TImplementation | instance |
Type Parameters
Name | Description |
---|---|
TContract | |
TImplementation |
AddTransient<TImplementation>()
Adds an implementation as a transient on the container.
Declaration
public void AddTransient<TImplementation>()
where TImplementation : class
Type Parameters
Name | Description |
---|---|
TImplementation |
Remarks
It can not be an abstract or interface type
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when using a abstract class or an interface |
AddTransient<TContract, TImplementation>()
Adds an implementation to a contract as transient on the container
Declaration
public void AddTransient<TContract, TImplementation>()
where TImplementation : class, TContract
Type Parameters
Name | Description |
---|---|
TContract | |
TImplementation |
Remarks
It can not be an abstract or interface type
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when using a abstract class or an interface |
Clear()
Clears and releases resources from the container
Declaration
public void Clear()
CreateScope()
Creates a scoped context copy of this container
Declaration
public IContainerResolver CreateScope()
Returns
Type | Description |
---|---|
IContainerResolver |
Dispose()
Clears and releases resources from the container
Declaration
public void Dispose()
Resolve(Type)
Asks the container for a new instance of a type
Declaration
public object Resolve(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type |
Returns
Type | Description |
---|---|
System.Object |
Resolve<T>()
Asks the container for a new instance of a type
Declaration
public T Resolve<T>()
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |