StrangeIoC  0.6.0
The IoC/Binding Framework for Unity3D and C#
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public Member Functions | Properties | List of all members
strange.extensions.command.impl.Command Class Reference

Commands are where you place your business logic. More...

Inheritance diagram for strange.extensions.command.impl.Command:
strange.extensions.command.api.ICommand strange.extensions.pool.api.IPoolable strange.extensions.command.impl.EventCommand strange.extensions.sequencer.impl.SequenceCommand strange.extensions.sequencer.impl.EventSequenceCommand

Public Member Functions

virtual void Execute ()
 Override this! Execute() is where you place the logic for your Command.
 
virtual void Retain ()
 Keeps the Command in memory. Use only in conjunction with Release()
 
virtual void Release ()
 Allows a previous Retained Command to be disposed.
 
virtual void Restore ()
 Use/override this method to clean up the Command for recycling.
 
virtual void Fail ()
 Inidcates that the Command failed Used in sequential command groups to terminate the sequence.
 
void Cancel ()
 Inform the Command that further Execution has been terminated.
 

Properties

ICommandBinder commandBinder [get, set]
 Back reference to the CommandBinder that instantiated this Commmand.
 
IInjectionBinder injectionBinder [get, set]
 The InjectionBinder for this Context.
 
object data [get, set]
 
bool cancelled [get, set]
 
bool IsClean [get, set]
 
int sequenceId [get, set]
 
bool retain [get, set]
 
- Properties inherited from strange.extensions.command.api.ICommand
bool IsClean [get, set]
 Flag to indicate that a pooled Command has been restored to its pristine state. More...
 
bool retain [get]
 The property set by Retain and Release to indicate whether the Command should be cleaned up on completion of the Execute() method.
 
bool cancelled [get, set]
 The property set to true by a Cancel() call. More...
 
object data [get, set]
 A payload injected into the Command. Most commonly, this an IEvent.
 
int sequenceId [get, set]
 
- Properties inherited from strange.extensions.pool.api.IPoolable
bool retain [get]
 Is this instance retained? More...
 

Detailed Description

Commands are where you place your business logic.

In the MVCSContext setup, commands are mapped to IEvents. The firing of a specific event on the global event bus triggers the instantiation, injection and execution of any Command(s) bound to that event.

By default, commands are cleaned up immediately on completion of the Execute() method. For asynchronous Commands (e.g., calling a service and awaiting a response), call Retain() at the top of your Execute() method, which will prevent premature cleanup. But remember, having done so it is your responsipility to call Release() once the Command is complete.

Calling Fail() will terminate any sequence in which the Command is operating, but has no effect on Commands operating in parallel.


The documentation for this class was generated from the following file: