Class StaticFileBase
Helper class that can be used by IStaticFile 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 StaticFileBase : IStaticFile
Constructors
StaticFileBase(string)
Protected constructor.
Declaration
protected StaticFileBase(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The logical path to this file. |
Properties
Name
Returns the file name.
Declaration
public virtual string Name { get; }
Property Value
Type | Description |
---|---|
string |
Path
Returns the fully qualified Linux style path for the static file relative to the static root directory.
Declaration
public virtual string Path { get; }
Property Value
Type | Description |
---|---|
string |
Methods
OpenReader(Encoding)
Opens a text reader for the file contents.
note
You are responsible disposing the reader returned when you're done with it.
Declaration
public abstract TextReader OpenReader(Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
Encoding | encoding | Optionally specifies the text encoding. This defaults to UTF-8, |
Returns
Type | Description |
---|---|
TextReader | The TextReader. |
OpenReaderAsync(Encoding)
Asychronously opens a text reader for the file contents.
note
You are responsible disposing the reader returned when you're done with it.
Declaration
public abstract Task<TextReader> OpenReaderAsync(Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
Encoding | encoding | Optionally specifies the text encoding. This defaults to UTF-8, |
Returns
Type | Description |
---|---|
Task<TextReader> | The TextReader. |
OpenStream()
Opens a stream on the file contents.
note
You are responsible disposing the reader returned when you're done with it.
Declaration
public abstract Stream OpenStream()
Returns
Type | Description |
---|---|
Stream | The Stream. |
OpenStreamAsync()
Asychronously opens a stream on the file contents.
note
You are responsible disposing the reader returned when you're done with it.
Declaration
public abstract Task<Stream> OpenStreamAsync()
Returns
Type | Description |
---|---|
Task<Stream> | The Stream. |
ReadAllBytes()
Reads the file contents as bytes.
Declaration
public abstract byte[] ReadAllBytes()
Returns
Type | Description |
---|---|
byte[] | The file contents. |
ReadAllBytesAsync()
Asynchronously reads the file contents as bytes.
Declaration
public abstract Task<byte[]> ReadAllBytesAsync()
Returns
Type | Description |
---|---|
Task<byte[]> | The file contents. |
ReadAllText(Encoding)
Reads the file contents as a UTF-8 encoded string.
Declaration
public abstract string ReadAllText(Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
Encoding | encoding | Optionally specifies the text encoding. This defaults to UTF-8, |
Returns
Type | Description |
---|---|
string | The file contents. |
ReadAllTextAsync(Encoding)
Asynchronously reads the file contents as a UTF-8 encoded string.
Declaration
public abstract Task<string> ReadAllTextAsync(Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
Encoding | encoding | Optionally specifies the text encoding. This defaults to UTF-8, |
Returns
Type | Description |
---|---|
Task<string> | The file contents. |
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. |