A special type of
IDocument
that wraps an underlying
object, providing the object properties as metadata.
- Namespace
- Statiq
.Common - Interfaces
-
- IDocument
- IMetadata
- IReadOnlyDictionary
<string, object> - IReadOnlyCollection
<KeyValuePair <string, object> > - IEnumerable
<KeyValuePair <string, object> > - IEnumerable
- IDisplayable
- I
Content Provider Factory - ILogger
- ICacheCode
- Base Types
-
- object
graph BT
Type-->Base0["object"]
Type-.->Interface0["IDocument"]
click Interface0 "/api/Statiq.Common/IDocument"
Type-.->Interface1["IMetadata"]
click Interface1 "/api/Statiq.Common/IMetadata"
Type-.->Interface2["IReadOnlyDictionary<string, object>"]
Type-.->Interface3["IReadOnlyCollection<KeyValuePair<string, object>>"]
Type-.->Interface4["IEnumerable<KeyValuePair<string, object>>"]
Type-.->Interface5["IEnumerable"]
Type-.->Interface6["IDisplayable"]
click Interface6 "/api/Statiq.Common/IDisplayable"
Type-.->Interface7["IContentProviderFactory"]
click Interface7 "/api/Statiq.Common/IContentProviderFactory"
Type-.->Interface8["ILogger"]
Type-.->Interface9["ICacheCode"]
click Interface9 "/api/Statiq.Common/ICacheCode"
Type["ObjectDocument<T>"]
class Type type-node
Syntax
public sealed class ObjectDocument<T> : IDocument, IMetadata, IReadOnlyDictionary<string, object>,
IReadOnlyCollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>,
IEnumerable, IDisplayable, IContentProviderFactory, ILogger, ICacheCode
Remarks
Note that unlike
Document
and other Document<TDocument>
derived documents, settings are not "bubbled up" through the document metadata.
Type Parameters
Name | Description |
---|---|
T | The type of underlying object. |
Constructors
Properties
Name | Property Type | Summary |
---|---|---|
ContentProvider | IContentProvider |
The content provider responsible for creating content streams for the document.
|
Count | int | |
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.
|
Keys | IEnumerable |
|
Object | T |
The underlying object.
|
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() .
|
this[string] | object | |
Timestamp | long |
A timestamp when this document was created that helps ordering documents based on creation.
|
Values | IEnumerable |
Methods
Name | Return Value | Summary |
---|---|---|
Clone |
IDocument |
Clones this document.
|
ContainsKey |
bool | |
GetCacheCodeAsync |
Task |
Gets a deterministic hash appropriate for caching.
|
GetEnumerator |
IEnumerator |
|
GetRawEnumerator |
IEnumerator |
Enumerates raw key-value pairs
(I.e., the values have not been expanded similar to
TryGetRaw(string, object) ).
|
ToString |
string | |
TryGetRaw |
bool |
Tries to get the raw value for the specified key. This method will not materialize
IMetadataValue
values or process script strings the way the TryGetValue<TValue>(IMetadata, string, TValue) extension
and other get methods will. A System.Collections.Generic.KeyNotFoundException will be thrown for missing keys.
|
TryGetValue |
bool |
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.
From IDocumentExtensions
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Clone |
IDocument |
Clones this document.
|
Concat |
IEnumerable |
|
ContainsAnyKeys |
bool |
Determines whether the dictionary contains all the specified keys.
|
ContainsAnyKeys |
bool |
Determines whether the dictionary contains all the specified keys.
|
ContainsKeys |
bool |
Determines whether the dictionary contains all the specified keys.
|
ContainsKeys |
bool |
Determines whether the dictionary contains all the specified keys.
|
FilterMetadata |
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 |
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 |
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 |
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 |
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 |
DocumentList |
|
GetChildren |
DocumentList |
|
GetContentBytesAsync |
Task |
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.
From IDocumentExtensions
|
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.
From IDocumentExtensions
|
Get |
Task |
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.
From IDocumentExtensions
|
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.
From IDocumentExtensions
|
GetDateTime |
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 |
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 |
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 |
DocumentList |
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 |
DocumentList |
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 |
IEnumerable |
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 |
IEnumerable |
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 |
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 |
Gets an enumerable that enumerates key-value pairs.
|
GetInt |
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 |
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 |
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 |
IReadOnlyList |
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 |
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 |
T | |
GetNext |
T | |
GetPath |
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 |
T | |
GetPrevious |
T | |
GetPublishedDate |
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.
From IDocumentExtensions
|
GetPublishedDate |
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.
From IDocumentExtensions
|
GetRaw |
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 |
Gets an enumerable that enumerates raw key-value pairs
(I.e., the values have not been expanded similar to
TryGetRaw(string, object) ).
|
GetString |
string |
Formats a string value if it exists in the metadata, otherwise returns a default value.
|
GetString |
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).
From IDocumentExtensions
|
GroupByMany |
IEnumerable |
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.
From GroupByExtensions
|
GroupByMany |
IEnumerable |
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.
From GroupByExtensions
|
GroupByMany |
IEnumerable |
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.
From GroupByExtensions
|
GroupByMany |
IEnumerable |
Groups the elements of a sequence according to a specified key selector function
that returns a sequence of keys.
From GroupByExtensions
|
GroupByManyToMany |
IEnumerable |
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.
From GroupByExtensions
|
GroupByManyToMany |
IEnumerable |
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.
From GroupByExtensions
|
IdEquals |
bool |
Determines if a document is equal by comparing their IDs.
From IDocumentExtensions
|
IdEquals |
bool |
Determines if a document is equal by comparing their IDs.
From IDocumentExtensions
|
MediaTypeEquals |
bool |
Determines if the supplied media type equals the media type of the content.
From IDocumentExtensions
|
ParallelForEachAsync |
Task | |
ParallelSelectAsync |
Task |
Invokes an async selector in parallel.
|
Parallel |
Task |
Invokes an async selector that returns multiple results in parallel.
|
ParallelWhereAsync |
Task |
|
ParseHtmlAsync |
Task |
Gets an
IHtmlDocument by parsing the content of an IDocument .
|
RequireKeys |
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 |
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 |
bool |
Determines whether the items starts with the specified values.
|
StartsWith |
bool |
Determines whether the items starts with the specified values.
|
ThrowIfNull |
T |
From GuardExtensions
|
ToDocument |
IDocument | |
ToDocument |
IDocument | |
ToDocument |
IDocument | |
ToDocument |
IDocument | |
ToDocument |
IDocument | |
ToDocument |
IDocument | |
ToDocuments |
IEnumerable |
|
ToDocuments |
IEnumerable |
|
ToDocuments |
IEnumerable |
|
ToDocuments |
IEnumerable |
|
ToDocuments |
IEnumerable |
|
ToDocuments |
IEnumerable |
|
ToJson |
string | |
ToLookupMany |
ILookup |
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.
From ToLookupExtensions
|
ToLookupMany |
ILookup |
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.
From ToLookupExtensions
|
ToLookupMany |
ILookup |
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.
From ToLookupExtensions
|
ToLookupMany |
ILookup |
Creates a lookup from a sequence according to a specified key selector function
that returns a sequence of keys.
From ToLookupExtensions
|
ToLookupManyToMany |
ILookup |
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.
From ToLookupExtensions
|
ToLookupManyToMany |
ILookup |
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.
From ToLookupExtensions
|
ToSafeDisplayString |
string |
A safe display string that can be used for logging and returns "null" when the
underlying object is null.
|
ToStringTable |
string | |
TryGetValue |
bool |
Tries to get the value for the specified key.
|
WithoutSettings |
IMetadata | |
XAttribute |
XAttribute | |
XAttribute |
XAttribute | |
XAttribute |
XAttribute | |
XAttribute |
XAttribute |
Gets an XML attribute for the given metadata key.
|
XAttribute |
XAttribute |
Gets an XML attribute for the given metadata key.
The name of the attribute will be the lower-case key name.
|
XElement |
XElement | |
XElement |
XElement | |
XElement |
XElement | |
Yield |
IEnumerable |
Returns a document enumerable given a single document. This is just a convenience
method for converting a single document into an
IEnumerable<T> .
|
YieldAsync |
Task |
Returns a document enumerable given a single document. This is just a convenience
method for converting a single document into an
IEnumerable<T> .
|