StrangeIoC
0.6.0
The IoC/Binding Framework for Unity3D and C#
|
The Binding form for the Injection system. More...
Public Member Functions | |
IInjectionBinding | ToSingleton () |
Map the Binding to a Singleton so that every GetInstance() on the Binder Key returns the same imstance. | |
IInjectionBinding | ToValue (object o) |
Map the Binding to a stated instance so that every GetInstance() on the Binder Key returns the provided imstance. Sets type to Value. | |
IInjectionBinding | SetValue (object o) |
Map the Binding to a stated instance so that every GetInstance() on the Binder Key returns the provided imstance. Does not set type. | |
IInjectionBinding | CrossContext () |
Map the binding and give access to all contexts in hierarchy. | |
IInjectionBinding | ToInject (bool value) |
Boolean setter to optionally override injection. If false, the instance will not be injected after instantiation. | |
new IInjectionBinding | Bind< T > () |
Bind is the same as Key, but permits Binder syntax: Bind<T>().Bind<T>() | |
new IInjectionBinding | Bind (object key) |
Bind is the same as Key, but permits Binder syntax: Bind<T>().Bind<T>() | |
new IInjectionBinding | To< T > () |
Set the Binding's value to a Type. | |
new IInjectionBinding | To (object o) |
Set the Binding's value to a value, such as a string or class instance. | |
new IInjectionBinding | ToName< T > () |
Qualify a binding using a marker type. | |
new IInjectionBinding | ToName (object o) |
Qualify a binding using a value, such as a string or class instance. | |
new IInjectionBinding | Named< T > () |
Retrieve a binding if the supplied name matches, by Type. | |
new IInjectionBinding | Named (object o) |
Retrieve a binding if the supplied name matches, by value. | |
Public Member Functions inherited from strange.framework.api.IBinding | |
void | RemoveKey (object o) |
Remove a specific key from the binding. | |
void | RemoveValue (object o) |
Remove a specific value from the binding. | |
void | RemoveName (object o) |
Remove a name from the binding. | |
IBinding | Weak () |
Properties | |
bool | isCrossContext [get] |
bool | toInject [get] |
Get the parameter that specifies whether this Binding allows an instance to be injected. | |
InjectionBindingType | type [get, set] |
Get and set the InjectionBindingType. More... | |
new object | key [get] |
new object | name [get] |
new object | value [get] |
new Enum | keyConstraint [get, set] |
new Enum | valueConstraint [get, set] |
Properties inherited from strange.framework.api.IBinding | |
object | key [get] |
Get the binding''s key. | |
object | name [get] |
Get the binding's name. | |
object | value [get] |
Get the binding's value. | |
Enum | keyConstraint [get, set] |
Get or set a MANY or ONE constraint on the Key. | |
Enum | valueConstraint [get, set] |
Get or set a MANY or ONE constraint on the Value. | |
bool | isWeak [get] |
The Binding form for the Injection system.
The InjectionBinding allows mapping to three core types:
GetInstance()
on the Binder Key returns a new imstance GetInstance()
on the Binder Key returns the same imstance GetInstance()
on the Binder Key returns the provided imstance Named injections are supported, thus:
Bind<IMyInterface>().To<MyInterfaceImplementer>().ToName(SomeEnum.VALUE);
returns a MyInterfaceImplementer instance only to injections that specifically tag SomeEnum.Value. This will be the same instance whenever it is called.
You can also map multiple Keys, allowing for polymorphic binding. This allows you to match two or more interfaces to a single class or value.
Bind<IFirstInterface>().Bind<ISecondInterface>().To<PolymorphicClass>();
Note that while you can bind multiple keys to an InjectionBinding, you can only bind one value. (The Injection system needs to know which concrete class you want created.)
|
getset |
Get and set the InjectionBindingType.