Class Container
Represents a dependency injection container.
Inheritance
Implements
Namespace: AlchemyBow.Core.IoC
Assembly: AlchemyBow.Core.dll
Syntax
public sealed class Container : IBindOnlyContainer
Constructors
Container()
Creates an instance of the class.
Declaration
public Container()
Methods
AddRangeToDynamicCollectionBinding<TCollection, TItem>(IEnumerable<TItem>)
Ensures that there is a key-value pair for the dynamic collection and adds specified items.
Declaration
public void AddRangeToDynamicCollectionBinding<TCollection, TItem>(IEnumerable<TItem> items)
where TCollection : ICollection<TItem>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | items | The items to add. |
Type Parameters
Name | Description |
---|---|
TCollection | The key of the dynamic collection. |
TItem | The type of items in the collection. |
Remarks
Informs the container that it should inject dependencies to the instance of the collection but not into the items. (The dependencies are injected during the resolve process.)
AddToDynamicCollectionBinding<TCollection, TItem>(TItem)
Ensures that there is a key-value pair for the dynamic collection and adds the specified item.
Declaration
public void AddToDynamicCollectionBinding<TCollection, TItem>(TItem item)
where TCollection : ICollection<TItem>
Parameters
Type | Name | Description |
---|---|---|
TItem | item | The item to add. |
Type Parameters
Name | Description |
---|---|
TCollection | The key of the dynamic collection. |
TItem | The type of items in the collection. |
Remarks
Informs the container that it should inject dependencies to the instance of the collection but not into the item. (The dependencies are injected during the resolve process.)
Bind(Type, Object)
Declares a new key-value pair and informs the container that it should inject dependencies to the instance of the value.
Declaration
public void Bind(Type key, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | key | The key. |
System.Object | value | The instance of the value. |
Remarks
The dependencies are injected during the resolve process.
Bind<TKey>(TKey)
Declares a new key-value pair and informs the container that it should inject dependencies to the instance of the value.
Declaration
public void Bind<TKey>(TKey value)
Parameters
Type | Name | Description |
---|---|---|
TKey | value | The instance of the value. |
Type Parameters
Name | Description |
---|---|
TKey |
Remarks
The dependencies are injected during the resolve process.
BindInaccessible(Object)
Informs the container that it should inject dependencies to the instance.
Declaration
public void BindInaccessible(object instance)
Parameters
Type | Name | Description |
---|---|---|
System.Object | instance | The instance to inform about. |
Remarks
The dependencies are injected during the resolve process.
CopyContent(Container, Container, Boolean)
Copies the content of the source container to the target container.
Declaration
public static void CopyContent(Container source, Container target, bool sealDynamicCollections)
Parameters
Type | Name | Description |
---|---|---|
Container | source | The source container. |
Container | target | The target container. |
System.Boolean | sealDynamicCollections | If |
EnsureDynamicCollectionBinding<TCollection>()
Ensures that there is a key-value pair for the dynamic collection.
Declaration
public void EnsureDynamicCollectionBinding<TCollection>()
Type Parameters
Name | Description |
---|---|
TCollection | The key of the dynamic collection. |
Resolve<T>()
Resolves the specified key.
Declaration
public T Resolve<T>()
Returns
Type | Description |
---|---|
T | The resolved value that was associated to the key. |
Type Parameters
Name | Description |
---|---|
T | The key to resolve. |
ResolveAllBindings()
Resolves all bindings.
Declaration
public void ResolveAllBindings()