StrangeIoC
0.6.0
The IoC/Binding Framework for Unity3D and C#
|
A Binder that implements Dependency Injection in StrangeIoC. More...
Public Member Functions | |
object | GetInstance (Type key, object name) |
Retrieve an Instance based on a key/name combo. More... | |
T | GetInstance< T > (object name) |
Retrieve an Instance based on a key/name combo. More... | |
int | Reflect (List< Type > list) |
Reflect all the types in the list Return the number of types in the list, which should be equal to the list length. | |
int | ReflectAll () |
Reflect all the types currently registered with InjectionBinder Return the number of types reflected, which should be equal to the number of concrete classes you've mapped. More... | |
void | ResolveBinding (IBinding binding, object key) |
Places individual Bindings into the bindings Dictionary as part of the resolving process More... | |
IInjectionBinding | Bind< T > () |
IInjectionBinding | Bind (Type key) |
IBinding | Bind (object key) |
IInjectionBinding | GetBinding< T > () |
IInjectionBinding | GetBinding< T > (object name) |
IInjectionBinding | GetBinding (object key) |
IInjectionBinding | GetBinding (object key, object name) |
void | Unbind< T > () |
void | Unbind< T > (object name) |
void | Unbind (object key) |
void | Unbind (object key, object name) |
void | Unbind (IBinding binding) |
Public Member Functions inherited from strange.framework.api.IInstanceProvider | |
T | GetInstance< T > () |
Retrieve an Instance based on the key. More... | |
object | GetInstance (Type key) |
Retrieve an Instance based on the key. More... | |
Properties | |
IInjector | injector [get, set] |
Get or set an Injector to use. By default, Injector instantiates it's own, but that can be overridden. | |
A Binder that implements Dependency Injection in StrangeIoC.
Keys in this Binder are always Types, that is, they represent either Classes or Interfaces, not values. Values may be either Types or values, depending on the situation.
The nature of the instance returned by GetInstance()
depends on how that Key was mapped.
examples:
//Returns a new instance of SimpleInterfaceImplementer.
Bind<ISimpleInterface>().To<SimpleInterfaceImplementer>();
//Returns a Singleton instance of SimpleInterfaceImplementer.
Bind<ISimpleInterface>().To<SimpleInterfaceImplementer>().ToSingleton();
//Returns a Singleton instance of SimpleInterfaceImplementer.
Bind<ISimpleInterface>().ToValue(new SimpleInterfaceImplementer());
//Returns the value 42.
Bind<int>().ToValue(42);
//Returns a named instance of SimpleInterfaceImplementer for those whose //injections specify this name. Note that once requested, this //same instance will be returned on any future request for that named instance.
Bind<ISimpleInterface>().To<SimpleInterfaceImplementer>().ToName(SomeEnum.MY_ENUM);
//Raises an Exception. string does not Implement ISimpleInterface.
Bind<ISimpleInterface>().To<string>();
object strange.extensions.injector.api.IInjectionBinder.GetInstance | ( | Type | key, |
object | name | ||
) |
Retrieve an Instance based on a key/name combo.
ex. injectionBinder.Get(typeof(ISomeInterface), SomeEnum.MY_ENUM);
Implemented in strange.extensions.injector.impl.InjectionBinder.
T strange.extensions.injector.api.IInjectionBinder.GetInstance< T > | ( | object | name) |
Retrieve an Instance based on a key/name combo.
ex. injectionBinder.Get<cISomeInterface>(SomeEnum.MY_ENUM);
Implemented in strange.extensions.injector.impl.InjectionBinder.
int strange.extensions.injector.api.IInjectionBinder.ReflectAll | ( | ) |
Reflect all the types currently registered with InjectionBinder Return the number of types reflected, which should be equal to the number of concrete classes you've mapped.
Implemented in strange.extensions.injector.impl.InjectionBinder.
void strange.extensions.injector.api.IInjectionBinder.ResolveBinding | ( | IBinding | binding, |
object | key | ||
) |
Places individual Bindings into the bindings Dictionary as part of the resolving process
Note that while some Bindings may store multiple keys, each key takes a unique position in the bindings Dictionary.
Conflicts in the course of fluent binding are expected, but GetBinding will throw an error if there are any unresolved conflicts.
Implemented in strange.extensions.injector.impl.CrossContextInjectionBinder.