IDocument Interface
Contains content and metadata for each item as it propagates through the pipeline.
Namespace
Statiq.Common
Interfaces
Implementing Types
graph BT Type-.->Interface0["IMetadata"] click Interface0 "/api/Statiq.Common/IMetadata" Type-.->Interface1["IReadOnlyDictionary<string, object>"] Type-.->Interface2["IReadOnlyCollection<KeyValuePair<string, object>>"] Type-.->Interface3["IEnumerable<KeyValuePair<string, object>>"] Type-.->Interface4["IEnumerable"] Type-.->Interface5["IDisplayable"] click Interface5 "/api/Statiq.Common/IDisplayable" Type-.->Interface6["IContentProviderFactory"] click Interface6 "/api/Statiq.Common/IContentProviderFactory" Type-.->Interface7["ILogger"] Type-.->Interface8["ICacheCode"] click Interface8 "/api/Statiq.Common/ICacheCode" Type["IDocument"] class Type type-node Implementing0["TestDocument"]-.->Type click Implementing0 "/api/Statiq.Testing/TestDocument" Implementing1["ObjectDocument<T>"]-.->Type click Implementing1 "/api/Statiq.Common/ObjectDocument_1" Implementing2["Document"]-.->Type click Implementing2 "/api/Statiq.Common/Document" Implementing3["Document<TDocument>"]-.->Type click Implementing3 "/api/Statiq.Common/Document_1"

Syntax

public interface IDocument : IMetadata, IReadOnlyDictionary<string, object>, 
    IReadOnlyCollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, 
    IEnumerable, IDisplayable, IContentProviderFactory, ILogger, ICacheCode

Fields

Name Field Type Constant Value Summary
Properties ImmutableHashSet<string>
A hash of the property names in IDocument generated using reflection (generally intended for internal use).
static
TimestampStopwatch Stopwatch
Provides a stopwatch that can be used by implementations to set the Timestamp, typically by getting System.Diagnostics.Stopwatch.ElapsedTicks in the Timestamp initializer.
static

Properties

Name Property Type Summary
ContentProvider IContentProvider
The content provider responsible for creating content streams for the document.
Destination NormalizedPath
The destination of the document. Can be either relative or absolute.
Id Guid
An identifier that is generated when the document is created and stays the same after cloning.
Source NormalizedPath
An identifier for the document meant to reflect the source of the data. These should be unique (such as a file name). This property is always an absolute path. If you want to get a relative path, use GetRelativeInputPath().
Timestamp long
A timestamp when this document was created that helps ordering documents based on creation.

Methods

Extension Methods

Name Value Summary
AsDynamic() dynamic
Presents the metadata of a document as a dynamic object. Cast the return object to IDocument to convert it back to a document.
Clone(IContentProvider) IDocument
Clones this document.
Clone(IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
Clones this document.
Clone(IEnumerable<KeyValuePair<string, object>>, Stream, string) IDocument
Clones this document.
Clone(IEnumerable<KeyValuePair<string, object>>, string, string) IDocument
Clones this document.
Clone(NormalizedPath, IContentProvider) IDocument
Clones this document.
Clone(NormalizedPath, IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
Clones this document.
Clone(NormalizedPath, IEnumerable<KeyValuePair<string, object>>, Stream, string) IDocument
Clones this document.
Clone(NormalizedPath, IEnumerable<KeyValuePair<string, object>>, string, string) IDocument
Clones this document.
Clone(NormalizedPath, NormalizedPath, IContentProvider) IDocument
Clones this document.
Clone(NormalizedPath, NormalizedPath, Stream, string) IDocument
Clones this document.
Clone(NormalizedPath, NormalizedPath, string, string) IDocument
Clones this document.
Clone(NormalizedPath, Stream, string) IDocument
Clones this document.
Clone(NormalizedPath, string, string) IDocument
Clones this document.
Clone(Stream, string) IDocument
Clones this document.
Clone(string, string) IDocument
Clones this document.
Concat<KeyValuePair<string, object>>(KeyValuePair<string, object>) IEnumerable<T>
ContainsAnyKeys<string, object>(IEnumerable<string>) bool
Determines whether the dictionary contains all the specified keys.
ContainsAnyKeys<string, object>(string[]) bool
Determines whether the dictionary contains all the specified keys.
ContainsKeys<string, object>(IEnumerable<string>) bool
Determines whether the dictionary contains all the specified keys.
ContainsKeys<string, object>(string[]) bool
Determines whether the dictionary contains all the specified keys.
FilterMetadata(string[]) IMetadata
Gets a new filtered IMetadata containing only the specified keys and their values. If a key is not present in the current metadata, it will be ignored and will not be copied to the new metadata object.
Get(string, object) object
Gets the value for the specified key. This method never throws an exception. It will return the specified default value or null if the key is not found or is null.
Get<T>(string, T) T
Gets the value for the specified key. This method never throws an exception. It will return the specified default value if the key is not found or is null.
Get<T>(string) T
Gets the value for the specified key converted to the specified type. This method never throws an exception. It will return default(T) if the key is not found, is null, or the value cannot be converted to T.
GetBool(string, bool) bool
Gets the value for the specified key converted to a bool. This method never throws an exception. It will return the specified default value if the key is not found.
GetChildren(string) DocumentList<IDocument>
GetChildren() DocumentList<IDocument>
GetContentBytesAsync() Task<byte[]>
Gets the content associated with this document as a byte array. This will result in reading the entire content stream. It's preferred to read directly as a stream using GetContentStream(IDocument) if possible.
GetContentStream() Stream
Gets the content associated with this document as a Stream. The stream you get from this call must be disposed as soon as reading is complete.
GetContentStringAsync() Task<string>
Gets the content associated with this document as a string. This will result in reading the entire content stream. It's preferred to read directly as a stream using GetContentStream(IDocument) if possible.
GetContentTextReader() TextReader
Gets the content associated with this document as a TextReader. This is prefered over reading the stream as text since it might be optimized for text-based use cases. The TextReader you get from this call must be disposed as soon as reading is complete.
GetDateTime(string, DateTime) DateTime
Gets the value for the specified key converted to a DateTime. This method never throws an exception. It will return the specified default value if the key is not found.
GetDateTimeOffset(string, DateTimeOffset) DateTimeOffset
Gets the value for the specified key converted to a DateTimeOffset. This method never throws an exception. It will return the specified default value if the key is not found.
GetDocument(string, IDocument) IDocument
Gets the value for the specified key converted to a IDocument. This method never throws an exception. It will return null if the key is not found.
GetDocumentList(string) DocumentList<IDocument>
Gets the value for the specified key converted to a DocumentList<TDocument>. This method never throws an exception. It will return an empty list if the key is not found or if the key is found but contains no items that can be converted to IDocument.
GetDocumentList<TDocument>(string) DocumentList<TDocument>
Gets the value for the specified key converted to a DocumentList<TDocument>. This method never throws an exception. It will return an empty list if the key is not found or if the key is found but contains no items that can be converted to the specified document type.
GetDocuments(string, IReadOnlyList<IDocument>) IEnumerable<IDocument>
Gets the value for the specified key converted to a IReadOnlyList<IDocument>. This method never throws an exception. It will return null if the key is not found and an empty list if the key is found but contains no items that can be converted to IDocument.
GetDocuments<TDocument>(string, IReadOnlyList<TDocument>) IEnumerable<TDocument>
Gets the value for the specified key converted to a IReadOnlyList<TDocument>. This method never throws an exception. It will return null if the key is not found and an empty list if the key is found but contains no items that can be converted to the specified document type.
GetDynamic(string, object) dynamic
Gets the value associated with the specified key as a dynamic object. This is equivalent to calling as dynamic to cast the value.
GetEnumerable() IEnumerable<KeyValuePair<string, object>>
Gets an enumerable that enumerates key-value pairs.
GetInt(string, int) int
Gets the value for the specified key converted to an int. This method never throws an exception. It will return the specified default value if the key is not found.
GetLink(bool) string
Gets a link for the specified document using the document destination. Note that you can optionally include the host or not depending on if you want to generate host-specific links. By default, the host is not included so that sites work the same on any server including the preview server.
GetLink(string, bool) string
Gets a link for the specified document using the document destination. Note that you can optionally include the host or not depending on if you want to generate host-specific links. By default, the host is not included so that sites work the same on any server including the preview server.
GetList<T>(string, IReadOnlyList<T>) IReadOnlyList<T>
Gets the value for the specified key converted to a IReadOnlyList<T>. This method never throws an exception. It will return the specified default value if the key is not found. Note that if the value is atomic, the conversion operation will succeed and return a list with one item.
GetMetadata(string, IMetadata) IMetadata
Gets the value for the specified key converted to a nested IMetadata. This method never throws an exception. It will return null if the key is not found.
GetNext<KeyValuePair<string, object>>(KeyValuePair<string, object>, IEqualityComparer<KeyValuePair<string, object>>) T
GetNext<KeyValuePair<string, object>>(KeyValuePair<string, object>) T
GetPath(string, NormalizedPath) NormalizedPath
Gets the value for the specified key converted to a NormalizedPath. This method never throws an exception. It will return the specified default value if the key is not found.
GetPrevious<KeyValuePair<string, object>>(KeyValuePair<string, object>, IEqualityComparer<KeyValuePair<string, object>>) T
GetPrevious<KeyValuePair<string, object>>(KeyValuePair<string, object>) T
GetPublishedDate(bool) DateTime
Gets the published date by first checking metadata for Published, then checking for a file name prefix of the form "yyyy/mm/dd-" (or the locale equivalent), then using the last modified date of the file.
GetPublishedDate(IExecutionContext, bool) DateTime
Gets the published date by first checking metadata for Published, then checking for a file name prefix of the form "yyyy/mm/dd-" (or the locale equivalent), then using the last modified date of the file.
GetRaw(string) object
Gets the raw value for the specified key. This method will not materialize IMetadataValue values the way other get methods will. A System.Collections.Generic.KeyNotFoundException will be thrown for missing keys.
GetRawEnumerable() IEnumerable<KeyValuePair<string, object>>
Gets an enumerable that enumerates raw key-value pairs (I.e., the values have not been expanded similar to TryGetRaw(string, object)).
GetString(string, Func<string, string>, string) string
Formats a string value if it exists in the metadata, otherwise returns a default value.
GetString(string, string) string
Gets the value for the specified key converted to a string. This method never throws an exception. It will return the specified default value if the key is not found.
GetTitle() string
Gets a normalized title derived from the document source (or Title if defined).
GroupByMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, TElement>, IEqualityComparer<TKey>) IEnumerable<IGrouping<TKey, TElement>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys. The keys are compared by using a comparer and each group's elements are projected by using a specified function.
GroupByMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, TElement>) IEnumerable<IGrouping<TKey, TElement>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys and projects the elements for each group by using a specified function.
GroupByMany<KeyValuePair<string, object>, TKey>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, IEqualityComparer<TKey>) IEnumerable<IGrouping<TKey, TSource>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys and compares the keys by using a specified comparer.
GroupByMany<KeyValuePair<string, object>, TKey>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>) IEnumerable<IGrouping<TKey, TSource>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys.
GroupByManyToMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, IEnumerable<TElement>>, IEqualityComparer<TKey>) IEnumerable<IGrouping<TKey, TElement>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys. The keys are compared by using a comparer and each group's elements are projected by using a specified function that returns a sequence of elements.
GroupByManyToMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, IEnumerable<TElement>>) IEnumerable<IGrouping<TKey, TElement>>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys and projects the elements for each group by using a specified function that returns a sequence of elements.
IdEquals(IDocument) bool
Determines if a document is equal by comparing their IDs.
IdEquals<IDocument>(IDocument) bool
Determines if a document is equal by comparing their IDs.
MediaTypeEquals(string) bool
Determines if the supplied media type equals the media type of the content.
ParallelForEachAsync<KeyValuePair<string, object>>(Func<KeyValuePair<string, object>, Task>, CancellationToken) Task
ParallelSelectAsync<KeyValuePair<string, object>, TResult>(Func<KeyValuePair<string, object>, Task<TResult>>, CancellationToken) Task<IEnumerable<TResult>>
Invokes an async selector in parallel.
ParallelSelectManyAsync<KeyValuePair<string, object>, TResult>(Func<KeyValuePair<string, object>, Task<IEnumerable<TResult>>>, CancellationToken) Task<IEnumerable<TResult>>
Invokes an async selector that returns multiple results in parallel.
ParallelWhereAsync<KeyValuePair<string, object>>(Func<KeyValuePair<string, object>, Task<bool>>, CancellationToken) Task<IEnumerable<TSource>>
ParseHtmlAsync(bool) Task<IHtmlDocument>
Gets an IHtmlDocument by parsing the content of an IDocument.
RequireKeys<string, object>(IEnumerable<string>) void
Verifies that a dictionary contains all requires keys. An System.ArgumentException will be thrown if the specified keys are not all present in the dictionary.
RequireKeys<string, object>(string[]) void
Verifies that a dictionary contains all requires keys. An System.ArgumentException will be thrown if the specified keys are not all present in the dictionary.
StartsWith<KeyValuePair<string, object>>(IEnumerable<KeyValuePair<string, object>>, IEqualityComparer<KeyValuePair<string, object>>) bool
Determines whether the items starts with the specified values.
StartsWith<KeyValuePair<string, object>>(IEnumerable<KeyValuePair<string, object>>) bool
Determines whether the items starts with the specified values.
ThrowIfNull<IDocument>(string) T
ToDocument<IDocument>(IContentProvider) IDocument
ToDocument<IDocument>(IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToDocument<IDocument>(NormalizedPath, IContentProvider) IDocument
ToDocument<IDocument>(NormalizedPath, IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToDocument<IDocument>(NormalizedPath, NormalizedPath, IContentProvider) IDocument
ToDocument<IDocument>(NormalizedPath, NormalizedPath, IEnumerable<KeyValuePair<string, object>>, IContentProvider) IDocument
ToDocuments<KeyValuePair<string, object>>(Func<KeyValuePair<string, object>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<string, object>>(Func<KeyValuePair<string, object>, IEnumerable<KeyValuePair<string, object>>>, Func<KeyValuePair<string, object>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<string, object>>(Func<KeyValuePair<string, object>, NormalizedPath>, Func<KeyValuePair<string, object>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<string, object>>(Func<KeyValuePair<string, object>, NormalizedPath>, Func<KeyValuePair<string, object>, IEnumerable<KeyValuePair<string, object>>>, Func<KeyValuePair<string, object>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<string, object>>(Func<KeyValuePair<string, object>, NormalizedPath>, Func<KeyValuePair<string, object>, NormalizedPath>, Func<KeyValuePair<string, object>, IContentProvider>) IEnumerable<IDocument>
ToDocuments<KeyValuePair<string, object>>(Func<KeyValuePair<string, object>, NormalizedPath>, Func<KeyValuePair<string, object>, NormalizedPath>, Func<KeyValuePair<string, object>, IEnumerable<KeyValuePair<string, object>>>, Func<KeyValuePair<string, object>, IContentProvider>) IEnumerable<IDocument>
ToJson(JsonSerializerOptions) string
ToLookupMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, TElement>, IEqualityComparer<TKey>) ILookup<TKey, TElement>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys. The keys are compared by using a comparer and each group's elements are projected by using a specified function.
ToLookupMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, TElement>) ILookup<TKey, TElement>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys and projects the elements for each group by using a specified function.
ToLookupMany<KeyValuePair<string, object>, TKey>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, IEqualityComparer<TKey>) ILookup<TKey, TSource>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys and compares the keys by using a specified comparer.
ToLookupMany<KeyValuePair<string, object>, TKey>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>) ILookup<TKey, TSource>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys.
ToLookupManyToMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, IEnumerable<TElement>>, IEqualityComparer<TKey>) ILookup<TKey, TElement>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys. The keys are compared by using a comparer and each group's elements are projected by using a specified function that returns a sequence of elements.
ToLookupManyToMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, IEnumerable<TElement>>) ILookup<TKey, TElement>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys and projects the elements for each group by using a specified function that returns a sequence of elements.
ToSafeDisplayString() string
A safe display string that can be used for logging and returns "null" when the underlying object is null.
ToStringTable<KeyValuePair<string, object>>(string[], Func<KeyValuePair<string, object>, object>[]) string
TryGetValue<TValue>(string, TValue) bool
Tries to get the value for the specified key.
WithoutSettings() IMetadata
XAttribute(string, Func<string, string>) XAttribute
XAttribute(string, Func<string, XAttribute>) XAttribute
XAttribute(string, string, Func<string, string>) XAttribute
XAttribute(string, string) XAttribute
Gets an XML attribute for the given metadata key.
XAttribute(string) XAttribute
Gets an XML attribute for the given metadata key. The name of the attribute will be the lower-case key name.
XElement(string, Func<string, object[]>) XElement
XElement(string, Func<string, XElement>) XElement
XElement(string, string, Func<string, object[]>) XElement
Yield<IDocument>() IEnumerable<TDocument>
Returns a document enumerable given a single document. This is just a convenience method for converting a single document into an IEnumerable<T>.
YieldAsync<IDocument>() Task<IEnumerable<TDocument>>
Returns a document enumerable given a single document. This is just a convenience method for converting a single document into an IEnumerable<T>.