TestFile Class
graph BT Type-->Base0["object"] Type-.->Interface0["IFile"] click Interface0 "/api/Statiq.Common/IFile" Type-.->Interface1["IFileSystemEntry"] click Interface1 "/api/Statiq.Common/IFileSystemEntry" Type-.->Interface2["IDisplayable"] click Interface2 "/api/Statiq.Common/IDisplayable" Type-.->Interface3["IContentProviderFactory"] click Interface3 "/api/Statiq.Common/IContentProviderFactory" Type-.->Interface4["ICacheCode"] click Interface4 "/api/Statiq.Common/ICacheCode" Type["TestFile"] class Type type-node

Syntax

public class TestFile : IFile, IFileSystemEntry, IDisplayable, IContentProviderFactory, ICacheCode

Constructors

Properties

Name Property Type Summary
CreationTime DateTime
Gets the time when the current entry was created.
Directory IDirectory
Gets the directory of the file.
Exists bool
Gets a value indicating whether this IFileSystemEntry exists.
LastWriteTime DateTime
Gets the time when the current entry was last written to.
Length long
Gets the length of the file.
MediaType string
Gets the media type of the file.
Path NormalizedPath
Gets the path to the file.

Methods

Name Return Value Summary
Delete() void
Deletes the file.
GetCacheCodeAsync() Task<int>
Gets a deterministic hash appropriate for caching.
GetContentProvider() IContentProvider
Gets a content provider.
GetContentProvider(string) IContentProvider
Gets a content provider with the specified media type.
Open(bool) Stream
Opens the file for reading and writing. This will either create the file if it doesn't exist or overwrite it if it does.
OpenAppend(bool) Stream
Opens the file for writing. This will either create the file if it doesn't exist or append to it if it does.
OpenRead() Stream
Opens the file for reading. If it does not exist, an exception will be thrown.
OpenText() TextReader
Opens the file for reading as text. If it does not exist, an exception will be thrown.
OpenWrite(bool) Stream
Opens the file for writing. This will either create the file if it doesn't exist or overwrite it if it does. You must manually call System.IO.Stream.SetLength(System.Int64) when done to ensure previously existing data is truncated.
ReadAllBytesAsync(CancellationToken) Task<byte[]>
Reads all bytes from the file.
ReadAllTextAsync(CancellationToken) Task<string>
Reads all text from the file.
Refresh() void
Refreshes any cached information about the file.
ToDisplayString() string
A display string that can be used for tracing.
ToString() string
WriteAllBytesAsync(byte[], bool, CancellationToken) Task
Writes the specified bytes to a file.
WriteAllTextAsync(string, bool, CancellationToken) Task
Writes the specified text to a file.

Extension Methods

Name Value Summary
AppendFromAsync(Stream, bool, CancellationToken) Task
Copies from a source stream to a file, appending to the end of the file.
CopyToAsync(IFile, bool, bool, CancellationToken) Task
Copies the file to the specified destination file, truncating any remaining data in the destination file.
CopyToAsync(Stream, CancellationToken) Task
Copies from a file to a destination stream.
DeserializeJsonAsync(Type, JsonSerializerOptions, CancellationToken) ValueTask<object>
DeserializeJsonAsync<TValue>(JsonSerializerOptions, CancellationToken) ValueTask<TValue>
DeserializeYaml(Type) object
DeserializeYaml<TValue>() TValue
MoveToAsync(IFile, CancellationToken) Task
Moves the file to the specified destination file, truncating any remaining data in the destination file.
SerializeJsonAsync(object, Type, bool, JsonSerializerOptions, CancellationToken) Task
SerializeJsonAsync(object, Type, JsonSerializerOptions, CancellationToken) Task
SerializeJsonAsync<TValue>(TValue, bool, JsonSerializerOptions, CancellationToken) Task
SerializeJsonAsync<TValue>(TValue, JsonSerializerOptions, CancellationToken) Task
SerializeYaml(object, bool) void
SerializeYaml(object, Type, bool) void
SerializeYaml(object, Type) void
SerializeYaml(object) void
SerializeYaml<TValue>(TValue, bool) void
SerializeYaml<TValue>(TValue) void
ThrowIfNull<TestFile>(string) T
ToDocument<TestFile>(IContentProvider) IDocument
ToDocument<TestFile>(IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToDocument<TestFile>(NormalizedPath, IContentProvider) IDocument
ToDocument<TestFile>(NormalizedPath, IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToDocument<TestFile>(NormalizedPath, NormalizedPath, IContentProvider) IDocument
ToDocument<TestFile>(NormalizedPath, NormalizedPath, IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToSafeDisplayString() string
A safe display string that can be used for logging and returns "null" when the underlying object is null.
WriteFromAsync(Stream, bool, bool, CancellationToken) Task
Copies from a source stream to a file, truncating any remaining data in the destination file.