Example of using the State Pattern in C#. More...
Public Member Functions | |
void | Run () |
Executes the example for the State Pattern in C#. | |
Private Member Functions | |
void | _State_DisplayText (string textToDisplay) |
Helper method to display text from the State exercise. Text is displayed with line numbers. | |
Example of using the State Pattern in C#.
The State pattern alters the behavior of the class hierarchy based on some state. This is the basis of a Finite State Machine.
In this exercise, the State class is a filter that parses text to remove C++-style line and block comments. It needs to be smart enough to ignore comment characters inside quotes.
The filtering process starts with creating the context that drives the state machine. Internal classes are provided for each state.
Definition at line 23 of file State_Exercise.cs.
|
inlineprivate |
Helper method to display text from the State exercise. Text is displayed with line numbers.
textToDisplay | Text to display. |
Definition at line 31 of file State_Exercise.cs.
Referenced by State_Exercise.Run().
|
inline |
Executes the example for the State Pattern in C#.
Definition at line 46 of file State_Exercise.cs.
References State_Exercise._State_DisplayText(), StateContext_Class.RemoveComments(), and textToFilter.
Referenced by Program.Run().