Interface IStaticFile
Describes a logical file in a static file system. This is used to abstract access to static files read from an assembly's embedded resources or potentially from other sources using Linux style paths.
This is currently used to emulate a tree of IStaticDirectory and IStaticFile instances loaded from an assembly's embedded resources via the GetResourceFileSystem(Assembly, string) extension method.
note
IMPORTANT: Implementations need to be thread-safe.
note
In general, file and directory name lookup case sensitivity should probably be case insensitive for most purposes but this is an implementation specific detail.
Namespace: Neon.IO
Assembly: Neon.Common.dll
Syntax
public interface IStaticFile
Properties
Name
Returns the file name.
Declaration
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
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
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
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
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
Task<Stream> OpenStreamAsync()
Returns
Type | Description |
---|---|
Task<Stream> | The Stream. |
ReadAllBytes()
Reads the file contents as bytes.
Declaration
byte[] ReadAllBytes()
Returns
Type | Description |
---|---|
byte[] | The file contents. |
ReadAllBytesAsync()
Asynchronously reads the file contents as bytes.
Declaration
Task<byte[]> ReadAllBytesAsync()
Returns
Type | Description |
---|---|
Task<byte[]> | The file contents. |
ReadAllText(Encoding)
Reads the file contents as a UTF-8 encoded string.
Declaration
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
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. |