Container for a string. Need to use a class that allows the text to be changed while the container (this class) remains constant. This way, operations can be applied to the text and the container's contents change but not the container (strings are immutable in C#; this dances around that problem). More...
Classes | |
class | Memento |
Represents a single memento (snapshot) of the text state before an operation is applied. The operation becomes the name of the memento for display purposes. More... | |
Public Member Functions | |
Memento_TextObject (string text) | |
Constructs a text object with an initial string. | |
IMemento | GetMemento (string operationName) |
Returns an IMemento object containing a snapshot of the text stored in this class instance. | |
void | RestoreMemento (IMemento memento) |
Sets the text in this class instance to the snapshot stored in the given IMemento object (which is assumed to be from this class). | |
override string | ToString () |
Converts the Memento_TextObject to a string (makes it easier to use the class in string formatting). | |
Properties | |
string | Text [get, set] |
Gets or sets the text in this TextObject. | |
Private Attributes | |
string | _text |
The text that can change in this Memento_TextObject class. | |
Container for a string. Need to use a class that allows the text to be changed while the container (this class) remains constant. This way, operations can be applied to the text and the container's contents change but not the container (strings are immutable in C#; this dances around that problem).
Definition at line 36 of file Memento.cs.
|
inline |
Constructs a text object with an initial string.
text | The initial string for the text object. |
Definition at line 121 of file Memento.cs.
References Memento_TextObject._text.
|
inline |
Returns an IMemento object containing a snapshot of the text stored in this class instance.
Definition at line 145 of file Memento.cs.
References Memento_TextObject._text.
Referenced by Memento_Exercise.Memento_SaveForUndo().
|
inline |
Sets the text in this class instance to the snapshot stored in the given IMemento object (which is assumed to be from this class).
memento | The IMemento object to restore to. |
Definition at line 156 of file Memento.cs.
References Memento_TextObject._text.
Referenced by Memento_Exercise.Memento_Undo().
|
inline |
Converts the Memento_TextObject to a string (makes it easier to use the class in string formatting).
Definition at line 167 of file Memento.cs.
References Memento_TextObject._text.
|
private |
The text that can change in this Memento_TextObject class.
Definition at line 110 of file Memento.cs.
Referenced by Command_TextObject.__init__(), Memento_TextObject.__init__(), Memento_TextObject.GetMemento(), Memento_TextObject.Memento_TextObject(), Command_TextObject.Reset(), Memento_TextObject.RestoreMemento(), Command_TextObject.Text(), Memento_TextObject.Memento.Text(), Memento_TextObject.Text(), Memento_TextObject.ToString(), and Command_TextObject.ToString().
|
getset |
Gets or sets the text in this TextObject.
Definition at line 129 of file Memento.cs.
Referenced by Memento_Exercise.Memento_Operation_Replace(), and Memento_Exercise.Memento_Operation_Reverse().