Represents an operation that can be applied to a TextObject. This class can handle two kinds of operations, one that takes no additional parameters and one that takes two additional string parameters. More...
Public Member Functions | |
Command (Command_TextObject source, string commandName, two_parameter_operation operation, string argument1, string argument2) | |
Constructor for a command that applies an operation to a TextObject, where the operation takes two parameters. | |
Command (Command_TextObject source, string commandName, no_parameter_operation operation) | |
Constructor for a command that applies an operation to a TextObject but does not take any additional parameters. | |
void | Execute () |
Execute the command on the TextObject. | |
override string | ToString () |
Convert this command to a string representation. | |
Private Attributes | |
Command_TextObject | _receiver |
string | _commandName |
two_parameter_operation? | _two_parameter_operation |
no_parameter_operation? | _no_parameter_operation |
string | _argument1 |
string | _argument2 |
Represents an operation that can be applied to a TextObject. This class can handle two kinds of operations, one that takes no additional parameters and one that takes two additional string parameters.
In a real program, the commands would be represented by an interface and concrete classes for each type of operation (based on additional parameters) would be used. This requires the calling entity to instantiate the appropriate concrete class as opposed to letting the C# compiler figure out the correct constructor based on parameters. Or the calling entity could use a class factory to create the concrete classes.
It is also conceivable to make this Command class general case in terms of passing in 0 or more arguments along with a delegate that takes 0 or more arguments. This complicates the actual calling of the delegate and obscures some of the functionality here but it would reduce the API to a single constructor and delegate. But then it's up to the user to get the right number of parameters into the command for the delegate.
Definition at line 111 of file Command.cs.
|
inline |
Constructor for a command that applies an operation to a TextObject, where the operation takes two parameters.
source | The TextObject to apply the operation to. |
commandName | Easy-to-read name of the command. |
operation | The operation to apply to the TextObject. |
argument1 | First argument to the operation (after the TextObject). |
argument2 | Second argument to the operation (after the TextObject). |
Definition at line 140 of file Command.cs.
References Command._argument1, Command._argument2, Command._commandName, Command._no_parameter_operation, Command._receiver, and Command._two_parameter_operation.
|
inline |
Constructor for a command that applies an operation to a TextObject but does not take any additional parameters.
source | The TextObject to apply the operation to. |
commandName | Easy-to-read name of the command. |
operation | The operation to apply to the TextObject. |
Definition at line 157 of file Command.cs.
References Command._argument1, Command._argument2, Command._commandName, Command._no_parameter_operation, Command._receiver, and Command._two_parameter_operation.
|
inline |
Execute the command on the TextObject.
Definition at line 170 of file Command.cs.
References Command._argument1, Command._argument2, Command._no_parameter_operation, Command._receiver, and Command._two_parameter_operation.
Referenced by Command_Exercise.Command_Save_And_Execute(), and Command_Exercise.Command_Undo().
|
inline |
Convert this command to a string representation.
Definition at line 186 of file Command.cs.
References Command._argument1, Command._argument2, Command._commandName, Command._no_parameter_operation, and Command._two_parameter_operation.
|
private |
Definition at line 126 of file Command.cs.
Referenced by Command.Command(), Command.Execute(), and Command.ToString().
|
private |
Definition at line 129 of file Command.cs.
Referenced by Command.Command(), Command.Execute(), and Command.ToString().
|
private |
Definition at line 117 of file Command.cs.
Referenced by Command.Command(), and Command.ToString().
|
private |
Definition at line 123 of file Command.cs.
Referenced by Command.Command(), Command.Execute(), and Command.ToString().
|
private |
Definition at line 114 of file Command.cs.
Referenced by Command.Command(), and Command.Execute().
|
private |
Definition at line 120 of file Command.cs.
Referenced by Command.Command(), Command.Execute(), and Command.ToString().