Individual {@link Command}s can be assembled into a {@link Chain}, which allows /// them to either complete the required processing or delegate further /// processing to the next {@link Command} in the {@link Chain}.
/// ///{@link Command} implementations should be designed in a thread-safe
/// manner, suitable for inclusion in multiple {@link Chain}s that might be
/// processed by different threads simultaneously. In general, this implies
/// that {@link Command} classes should not maintain state information in
/// instance variables. Instead, state information should be maintained via
/// suitable modifications to the attributes of the {@link Context} that is
/// passed to the Execute
command.
{@link Command} implementations typically retrieve and store state
/// information in the {@link Context} instance that is passed as a parameter
/// to the Execute
method, using particular keys into the
/// IDictionary
that can be acquired via
/// Context.Keys
.
///
///
To improve interoperability of /// {@link Command} implementations, a useful design pattern is to expose the /// key values used as Properties of the {@link Command} /// implementation class itself. For example, a {@link Command} that requires /// an input and an output key might implement the following properties:
/// ////// private string _InputKey = "input"; /// public string InputKey { /// get { return _InputKey; } /// set { _InputKey = value; } /// } /// /// private string _OutputKey = "output"; /// public string OutputKey { /// get { return _OutputKey; } /// set { _OutputKey = value; } /// } ////// ///
And the operation of accessing the "input" information in the context /// would be executed by calling:
/// ////// string input = context[getInputKey()] as string; ////// ///
instead of hard coding the key attribute. The use of the "Key" /// suffix on such property names is a useful convention to identify properties /// being used in this fashion, as opposed to properties that simply /// configure the internal operation of this {@link Command}.
///true
, or delegate remaining processing
/// to the next {@link ICommand} in a {@link IChain} containing this
/// {@link ICommand} by returning false
/// true
if the processing of this {@link Context}
/// has been completed, or false
if the processing
/// of this {@link IContext} should be delegated to a subsequent
/// {@link ICommand} in an enclosing {@link IChain}
///