Example of using the Composite Pattern in C#. More...
Public Member Functions | |
void | Run () |
Executes the example for the Composite Pattern in C#. | |
Private Member Functions | |
string | Composite_Exercise_FormatEntry (FileDirEntry entry, int depth) |
Format the specified entry for display. | |
void | Composite_Exercise_ShowEntry (FileDirEntry entry) |
Recursively display the contents of the hierarchical list of objects starting with the given object. | |
Example of using the Composite Pattern in C#.
The Composite pattern is used when a collection of objects is to be formed in a hierarchical form where each object needs to be treated like any other object but some objects can contain other objects.
This example uses a file structure of file and directories to represent each object type.
Definition at line 22 of file Composite_Exercise.cs.
|
inlineprivate |
Format the specified entry for display.
This is a recursive call.
entry | The FileDirEntry object to format |
depth | The current recursion depth. This is used as leading space. |
Definition at line 34 of file Composite_Exercise.cs.
References FileDirEntry.Children, Composite_Exercise.Composite_Exercise_FormatEntry(), FileDirEntry.FileDirType, FileDirEntry.Length, FileDirEntry.Name, and FileDirEntry.WhenModified.
Referenced by Composite_Exercise.Composite_Exercise_FormatEntry(), and Composite_Exercise.Composite_Exercise_ShowEntry().
|
inlineprivate |
Recursively display the contents of the hierarchical list of objects starting with the given object.
entry |
Definition at line 69 of file Composite_Exercise.cs.
References Composite_Exercise.Composite_Exercise_FormatEntry().
Referenced by Composite_Exercise.Run().
|
inline |
Executes the example for the Composite Pattern in C#.
Definition at line 80 of file Composite_Exercise.cs.
References Composite_Exercise.Composite_Exercise_ShowEntry(), and Composite_FileAccess.GetEntry().
Referenced by Program.Run().