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

Represents a Directory entry. More...

Inheritance diagram for DirEntry:
Inheritance graph
Collaboration diagram for DirEntry:
Collaboration graph

Public Member Functions

 DirEntry (string name, DateTime modDate, FileDirEntry[] children)
 Construct a DirEntry instance.
 
- Public Member Functions inherited from FileDirEntry
 FileDirEntry ()
 Default constructor.
 

Properties

override long Length [get]
 Retrieve the size of all children of this directory. The length is calculated on the first call and cached for subsequent calls.
 
override FileDirEntry[] Children [get]
 Retrieve the children of this node.
 
- Properties inherited from FileDirEntry
virtual FileDirTypes FileDirType [get, protected set]
 The type of this entry as represented by a value from the FileDirTypes enumeration.
 
virtual string Name [get, protected set]
 The name of this entry.
 
virtual long Length [get, protected set]
 The length in bytes of this entry. Directory entries are the sum of the length of all children.
 
virtual DateTime WhenModified [get, protected set]
 When this entry was last modified.
 
virtual ? FileDirEntry[] Children [get]
 The children of this entry. Is null if the entry can never have any children (that is, it isn't a container of other entries).
 

Private Attributes

List< FileDirEntry_children
 
long _length
 
bool _lengthSet
 

Detailed Description

Represents a Directory entry.

A directory entry contains 0 or more children, which can be a mix of file and directory entries.

A Directory's size is the sum of all children sizes.

Definition at line 135 of file Composite_FileDirEntry.cs.

Constructor & Destructor Documentation

◆ DirEntry()

DirEntry ( string  name,
DateTime  modDate,
FileDirEntry[]  children 
)
inline

Construct a DirEntry instance.

Parameters
nameName of the directory
modDatemodification date time of the entry
childrenArray of children. Must not be null but can be empty.
Exceptions
ArgumentNullExceptionThe list of children cannot be null but can be empty.

Definition at line 148 of file Composite_FileDirEntry.cs.

References DirEntry._children, FileDirEntry.FileDirType, FileDirEntry.Name, and FileDirEntry.WhenModified.

Member Data Documentation

◆ _children

List<FileDirEntry> _children
private

◆ _length

long _length
private

Definition at line 138 of file Composite_FileDirEntry.cs.

Referenced by FileDirEntry.Length(), and DirEntry.Length().

◆ _lengthSet

bool _lengthSet
private

Definition at line 139 of file Composite_FileDirEntry.cs.

Referenced by DirEntry.Length().

Property Documentation

◆ Children

override FileDirEntry [] Children
get

Retrieve the children of this node.

This is an override of the base class and uses a collection of children entries stored in the DirEntry class so the base class doesn't need to store it.

Definition at line 192 of file Composite_FileDirEntry.cs.

◆ Length

override long Length
get

Retrieve the size of all children of this directory. The length is calculated on the first call and cached for subsequent calls.

This is an override of the base class to provide different behavior.

Definition at line 167 of file Composite_FileDirEntry.cs.


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