Design Pattern Examples
Overview of object-oriented design patterns
Composite_FileAccess Class Reference

Static class containing functions for accessing a hardcoded "file" and "directory" hierarchy. More...

Collaboration diagram for Composite_FileAccess:
Collaboration graph

Static Public Member Functions

static FileDirEntry GetEntry (string filepath)
 Return a FileDirEntry object representing the specified file "path" in an internal list of data entries that is organized in a file/ directory structure.
 

Static Private Member Functions

static ? FileDirEntry _FindEntry (string filepath)
 Helper method to search the static data list for the specified file/dir entry.
 

Static Private Attributes

static FileDirEntry rootEntry
 

Detailed Description

Static class containing functions for accessing a hardcoded "file" and "directory" hierarchy.

Definition at line 24 of file Composite_FileAccess.cs.

Member Function Documentation

◆ _FindEntry()

static ? FileDirEntry _FindEntry ( string  filepath)
inlinestaticprivate

Helper method to search the static data list for the specified file/dir entry.

Parameters
filepathA "path" specifying the entry to find, with each component separated by '/'.
Returns
Returns a FileDirEntry object for the requested object; otherwise, returns null, indicating the entry was not found.

Definition at line 52 of file Composite_FileAccess.cs.

References FileDirEntry.Children, FileDirEntry.Length, and FileDirEntry.Name.

◆ GetEntry()

static FileDirEntry GetEntry ( string  filepath)
inlinestatic

Return a FileDirEntry object representing the specified file "path" in an internal list of data entries that is organized in a file/ directory structure.

Parameters
filepathA "path" specifying the entry to find, with each component separated by '/'.
Returns
Returns a FileDirEntry object representing the specified file entry.
Exceptions
FIleNotFoundExceptionThe specified file entry was not found.

Definition at line 118 of file Composite_FileAccess.cs.

References _FindEntry().

Referenced by Composite_Exercise.Run().

Member Data Documentation

◆ rootEntry

FileDirEntry rootEntry
staticprivate
Initial value:
=
new DirEntry("root", DateTime.Now, new FileDirEntry[] {
new FileEntry("FileA.txt", 101, DateTime.Now),
new FileEntry("FileB.txt", 102, DateTime.Now),
new FileEntry("FileC.txt", 103, DateTime.Now),
new DirEntry("subdir1", DateTime.Now, new FileDirEntry[] {
new FileEntry("FileD.txt", 104, DateTime.Now),
new FileEntry("FileE.txt", 105, DateTime.Now),
new DirEntry("subdir2", DateTime.Now, new FileDirEntry[] {
new FileEntry("FileF.txt", 106, DateTime.Now),
new FileEntry("FileG.txt", 107, DateTime.Now)
}),
}),
})
Represents a Directory entry.
Structure representing a File (FileEntry) or Directory (DirEntry) entry. This is included as the firs...

Definition at line 28 of file Composite_FileAccess.cs.


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