StrangeIoC
0.6.0
The IoC/Binding Framework for Unity3D and C#
|
A Binder that triggers the instantiation of Commands. More...
Public Member Functions | |
override IBinding | GetRawBinding () |
Generate an unpopulated IBinding in whatever concrete form the Binder dictates. | |
virtual void | ReactTo (object trigger) |
Trigger a key that unlocks one or more Commands. | |
virtual void | ReactTo (object trigger, object data) |
Trigger a key that unlocks one or more Commands and provide a data injection to that Command. | |
virtual void | Stop (object key) |
Called to halt execution of a currently running command group. | |
virtual void | ReleaseCommand (ICommand command) |
Release a previously retained Command. More... | |
Pool< T > | GetPool< T > () |
Retrieve the Pool of the specified type. | |
bool | Trigger< T > (object data) |
Cause this ITriggerable to access any provided Key in its Binder by the provided generic and data. More... | |
bool | Trigger (object key, object data) |
Cause this ITriggerable to access any provided Key in its Binder by the provided key and data. More... | |
new virtual ICommandBinding | Bind< T > () |
Bind a trigger Key by generic Type. | |
new virtual ICommandBinding | Bind (object value) |
Bind a trigger Key by value. | |
new virtual ICommandBinding | GetBinding< T > () |
Retrieve a binding based on the provided Type. | |
Public Member Functions inherited from strange.framework.impl.Binder | |
delegate void | BindingResolver (IBinding binding) |
A handler for resolving the nature of a binding during chained commands. | |
virtual IBinding | GetBinding (object key) |
Retrieve a binding based on the provided object. | |
virtual IBinding | GetBinding< T > (object name) |
Retrieve a binding based on the provided Key (generic)/Name combo. | |
virtual IBinding | GetBinding (object key, object name) |
Retrieve a binding based on the provided Key/Name combo. | |
virtual void | Unbind< T > () |
Remove a binding based on the provided Key (generic) | |
virtual void | Unbind (object key) |
Remove a binding based on the provided Key. | |
virtual void | Unbind< T > (object name) |
Remove a binding based on the provided Key (generic) / Name combo. | |
virtual void | Unbind (object key, object name) |
Remove a binding based on the provided Key / Name combo. | |
virtual void | Unbind (IBinding binding) |
Remove the provided binding from the Binder. | |
virtual void | RemoveValue (IBinding binding, object value) |
Remove a select value from the given binding. | |
virtual void | RemoveKey (IBinding binding, object key) |
Remove a select key from the given binding. | |
virtual void | RemoveName (IBinding binding, object name) |
Remove a select name from the given binding. | |
virtual void | ResolveBinding (IBinding binding, object key) |
This method places individual Bindings into the bindings Dictionary as part of the resolving process. More... | |
virtual void | OnRemove () |
The Binder is being removed Override this method to clean up remaining bindings. | |
Protected Member Functions | |
void | next (ICommandBinding binding, object data, int depth) |
virtual void | disposeOfSequencedData (object data) |
virtual ICommand | invokeCommand (Type cmd, ICommandBinding binding, object data, int depth) |
virtual ICommand | createCommand (object cmd, object data) |
ICommand | getCommand (Type type) |
void | trackCommand (ICommand command, ICommandBinding binding) |
void | executeCommand (ICommand command) |
override void | resolver (IBinding binding) |
The default handler for resolving bindings during chained commands. | |
virtual Pool | makePoolFromType (Type type) |
Protected Member Functions inherited from strange.framework.impl.Binder | |
void | registerNameConflict (object key, IBinding newBinding, IBinding existingBinding) |
Take note of bindings that are in conflict. More... | |
bool | isConflictCleared (Dictionary< IBinding, object > dict, IBinding binding) |
Returns true if the provided binding and the binding in the dict are no longer conflicting. | |
void | clearConflict (object key, object name, Dictionary< IBinding, object > dict) |
T[] | spliceValueAt< T > (int splicePos, object[] objectValue) |
object[] | spliceValueAt (int splicePos, object[] objectValue) |
Remove the item at splicePos from the list objectValue. | |
Protected Attributes | |
Dictionary< Type, Pool > | pools = new Dictionary<Type, Pool> () |
HashSet< ICommand > | activeCommands = new HashSet<ICommand>() |
Tracker for parallel commands in progress. | |
Dictionary< ICommand, ICommandBinding > | activeSequences = new Dictionary<ICommand, ICommandBinding> () |
Tracker for sequences in progress. | |
Protected Attributes inherited from strange.framework.impl.Binder | |
Dictionary< object, Dictionary < object, IBinding > > | bindings |
Dictionary of all bindings Two-layer keys. More... | |
Dictionary< object, Dictionary < IBinding, object > > | conflicts |
Properties | |
IInjectionBinder | injectionBinder [get, set] |
bool | usePooling [get, set] |
Properties inherited from strange.extensions.command.api.IPooledCommandBinder | |
bool | usePooling [get, set] |
Switch to disable pooling for those that don't want to use it. | |
A Binder that triggers the instantiation of Commands.
Commands are where the logic of your application belongs. These Commands typically focus on a single function, such as adding a View, requesting a service, reading from or saving to a model.
The act of binding events to Commands means that code needn't know anything about an event recipient, or even how the event will be used. For example, a Mediator might send out an event that two View objects collided. A Command would then determine that the result of that event was to Destroy both objects, tell a ScoreKeeper model to change the score and request a message be sent to the server. Whether that example means one Command or three is up to your coding preference... CommandBinder can trigger one Command or multiple Commands off the same event.
Note that CommandBinder also features sequencing. By default, CommandBinder fires all Commands in parallel. If your binding specifies InSequence()
, commands will run serially, with the option of suspending the chain at any time.
Example bindings:
Bind("someEvent").To<SomeCommand>(); //Works, but poor form to use strings. Use the next example instead Bind(EventMap.SOME_EVENT).To<SomeCommand>(); //Make it a constant Bind(ContextEvent.START).To<StartCommand>().Once(); //Destroy the binding immediately after a single use Bind(EventMap.END_GAME_EVENT).To<FirstCommand>().To<SecondCommand>().To<ThirdGCommand>().InSequence();
See Command for details on asynchronous Commands and cancelling sequences.
|
inlinevirtual |
Release a previously retained Command.
By default, a Command is garbage collected at the end of its Execute()
method. But the Command can be retained for asynchronous calls.
Implements strange.extensions.command.api.ICommandBinder.
|
inline |
Cause this ITriggerable to access any provided Key in its Binder by the provided key and data.
Implements strange.extensions.dispatcher.api.ITriggerable.
|
inline |
Cause this ITriggerable to access any provided Key in its Binder by the provided generic and data.
Implements strange.extensions.dispatcher.api.ITriggerable.