CommandPattern 1.0.0
This package contains a collection of classes and interfaces to allow for quick and consistent implementation of the command pattern across projects.
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
SadSapphicGames.CommandPattern.CompositeCommand Class Reference

A Command that is composed of multiple child commands, all of which are executed together and leave one record in the CommandStream's history. <remark> For more information on this type of object seek external documentation on the composite design pattern </remark> More...

Inheritance diagram for SadSapphicGames.CommandPattern.CompositeCommand:
SadSapphicGames.CommandPattern.Command SadSapphicGames.CommandPattern.ICommand SadSapphicGames.CommandPattern.NullCompositeCommand SadSapphicGames.CommandPattern.SimpleComposite

Public Member Functions

override void Execute ()
 Queues all of the child commands into the internal CommandStream and attempts to invoke all of them. Will throw an exception if one of its children fails after attempting to revert all its executed commands. More...
 
abstract void Execute ()
 Executes the command, do not invoke directly, instead use a CommandStream. More...
 
abstract void Execute ()
 Executes the function of the command More...
 

Protected Member Functions

virtual void AddChild (ICommand childCommand)
 Adds a Command to this objects children More...
 

Protected Attributes

List< ICommandsubCommands = new List<ICommand>()
 The child Commands that will be executed upon executing this object
 
CommandStream internalStream = new CommandStream()
 An internal CommandStream to provide more control of the execution of the subCommands of the Composite
 

Properties

int ChildCount [get]
 Number of child Commands included in this object
 

Detailed Description

A Command that is composed of multiple child commands, all of which are executed together and leave one record in the CommandStream's history. <remark> For more information on this type of object seek external documentation on the composite design pattern </remark>

Member Function Documentation

◆ AddChild()

virtual void SadSapphicGames.CommandPattern.CompositeCommand.AddChild ( ICommand  childCommand)
protectedvirtual

Adds a Command to this objects children

Parameters
childCommandThe Command to be added to the objects children

◆ Execute()

override void SadSapphicGames.CommandPattern.CompositeCommand.Execute ( )
virtual

Queues all of the child commands into the internal CommandStream and attempts to invoke all of them. Will throw an exception if one of its children fails after attempting to revert all its executed commands.

Be aware that if you override this method you will bypass the implemented failsafe's for children of the CompositeCommand failing such as attempting to undo executed commands

Exceptions
IrreversibleCompositeFailureExceptionIndicates one of the children of the CompositeCommand failed and it executed one or more commands that cannot be undone. TryExecuteNext will catch this exception and throw it upwards
ReversibleCompositeFailureExceptionIndicates one of the children of the CompositeCommand failed but it was able to undo all of its executed commands. TryExecuteNext will catch this exception and handle it by returning false.

Implements SadSapphicGames.CommandPattern.Command.


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