Class StaticDirectoryBase
Helper class that can be used by IStaticDirectory implementations.
note
Implementations derived from this class will use case insensitive file and directory name mapping.
Implements
Namespace: Neon.IO
Assembly: Neon.Common.dll
Syntax
public abstract class StaticDirectoryBase : IStaticDirectory
Constructors
StaticDirectoryBase(StaticDirectoryBase, StaticDirectoryBase, string)
Protected constructor.
Declaration
protected StaticDirectoryBase(StaticDirectoryBase root, StaticDirectoryBase parent, string name)
Parameters
Type | Name | Description |
---|---|---|
StaticDirectoryBase | root | The root directory or |
StaticDirectoryBase | parent | The parent directory or |
string | name | The directory name (this must be |
Properties
Directories
Returns the subdirectories present in this directory.
Declaration
protected virtual IEnumerable<StaticDirectoryBase> Directories { get; }
Property Value
Type | Description |
---|---|
IEnumerable<StaticDirectoryBase> |
Files
Returns the list of files present in this directory.
Declaration
protected virtual IEnumerable<StaticFileBase> Files { get; }
Property Value
Type | Description |
---|---|
IEnumerable<StaticFileBase> |
Name
Returns the directory name.
Declaration
public virtual string Name { get; }
Property Value
Type | Description |
---|---|
string |
Parent
Returns a reference to the parent directory or null
if this is the root directory
for a static file system.
Declaration
public virtual IStaticDirectory Parent { get; }
Property Value
Type | Description |
---|---|
IStaticDirectory |
Path
Returns the fully qualified Linux style path for the static directory relative to the static root directory.
Declaration
public virtual string Path { get; }
Property Value
Type | Description |
---|---|
string |
Methods
AddDirectory(StaticDirectoryBase)
Adds a subdirectory if it doesn't already exist.
Declaration
public StaticDirectoryBase AddDirectory(StaticDirectoryBase directory)
Parameters
Type | Name | Description |
---|---|---|
StaticDirectoryBase | directory | The child resource directory. |
Returns
Type | Description |
---|---|
StaticDirectoryBase | The existing StaticResourceDirectory or |
AddFile(StaticFileBase)
Adds a file.
Declaration
public void AddFile(StaticFileBase file)
Parameters
Type | Name | Description |
---|---|---|
StaticFileBase | file | The subdirectory. |
GetDirectories(string, SearchOption)
Returns the directories beneath the current directory, optionally matching directories by name as well as optionally searching for directories recursively.
Declaration
public virtual IEnumerable<IStaticDirectory> GetDirectories(string searchPattern = null, SearchOption options = SearchOption.TopDirectoryOnly)
Parameters
Type | Name | Description |
---|---|---|
string | searchPattern | Optionally specifies a directory name pattern using standard file system wildcards like [*] and [?]. This defaults to including all directories. |
SearchOption | options | Optionally require a recursive search. This defaults to TopDirectoryOnly. |
Returns
Type | Description |
---|---|
IEnumerable<IStaticDirectory> | The set of matching directories. |
GetDirectory(string)
Gets a directory via a Linux style path. This path can be absolute relative to the root directory or it can be relative to the current directory.
note
Relative paths including /../ notation to move up a directory or ./ to specify the current directory are not supported.
Declaration
public IStaticDirectory GetDirectory(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The file path (absolute or relative). |
Returns
Type | Description |
---|---|
IStaticDirectory | The directory. |
Exceptions
Type | Condition |
---|---|
FileNotFoundException | Thrown if the directory doesn't exist. |
GetFile(string)
Gets a file via a Linux style path. This path can be absolute relative to the root directory or it can be relative to the current directory.
note
Relative paths including /../ notation to move up a directory or ./ to specify the current directory are not supported.
Declaration
public virtual IStaticFile GetFile(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The file path (absolute or relative). |
Returns
Type | Description |
---|---|
IStaticFile | The file. |
Exceptions
Type | Condition |
---|---|
FileNotFoundException | Thrown if the file doesn't exist. |
GetFiles(string, SearchOption)
Returns the files beneath the current directory, optionally matching files by name as well as optionally searching recursively searching subdirectories..
Declaration
public virtual IEnumerable<IStaticFile> GetFiles(string searchPattern = null, SearchOption options = SearchOption.TopDirectoryOnly)
Parameters
Type | Name | Description |
---|---|---|
string | searchPattern | Optionally specifies a file name pattern using standard file system wildcards like [*] and [?]. This defaults to including all files. |
SearchOption | options | Optionally requires a recursive search. This defaults to TopDirectoryOnly. |
Returns
Type | Description |
---|---|
IEnumerable<IStaticFile> | The set of matching files. |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |