IDocument Interface

Summary

Contains content and metadata for each item as it propagates through the pipeline.
Assembly
Wyam.Common.dll
Namespace
Wyam.Common.Documents
Interfaces
  • IMetadata
  • IReadOnlyDictionary<TKey, TValue>
  • IReadOnlyCollection<T>
  • IEnumerable<T>
  • IEnumerable
  • IDisposable
Implementing Types
graph TD Interface0["IMetadata"]-.->Type click Interface0 "/api/Wyam.Common.Meta/IMetadata" Interface1["IReadOnlyDictionary<TKey, TValue>"]-.->Type Interface2["IReadOnlyCollection<T>"]-.->Type Interface3["IEnumerable<T>"]-.->Type Interface4["IEnumerable"]-.->Type Interface5["IDisposable"]-.->Type Type["IDocument"] class Type type-node Type-.->Implementing0["TestDocument"] click Implementing0 "/api/Wyam.Testing.Documents/TestDocument" Type-.->Implementing1["CustomDocument"] click Implementing1 "/api/Wyam.Core.Documents/CustomDocument"

Syntax

public interface IDocument : IMetadata, IReadOnlyDictionary<string, object>, 
    IReadOnlyCollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, 
    IEnumerable, IDisposable

Remarks

Documents are immutable so you must call one of the GetDocument methods of Wyam.Common.Documents.IDocumentFactory to create a new document. Implements Wyam.Common.Meta.IMetadata and all metadata calls are passed through to the document's internal Wyam.Common.Meta.IMetadata instance (exposed via the Wyam.Common.Documents.IDocument.Metadata property). Note that both the Wyam.Common.Documents.IDocument.Content property and the result of the Wyam.Common.Documents.IDocument.GetStream method are guaranteed not to be null. When a document is created, either a string or a Stream is provided. Whenever the other of the two is requested, the system will convert the current representation for you.

Properties

Name Value Summary
Content string
Gets the content associated with this document as a string. This will result in reading the entire content stream.
Id string
An identifier that is generated when the document is created and stays the same after cloning.
Metadata IMetadata
Gets the metadata associated with this document.
Source FilePath
An identifier for the document meant to reflect the source of the data. These should be unique (such as a file name).
WithoutSettings IMetadata
Gets the metadata for this document without any global settings included.

Methods

Name Value Summary
GetStream() Stream
Gets the content associated with this document as a Stream. The underlying stream will be reset to position 0 each time this method is called. The stream you get from this call must be disposed as soon as reading is complete. Other threads will block on this call until the previously returned stream is disposed.
SourceString() string
Gets a string representation of the source that's guaranteed non-null, used primarily for trace messages.

Extension Methods

Name Value Summary
Bool(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.
DateTime(string, DateTime) DateTime
Gets the value for the specified key converted to a Wyam.Common.Meta.MetadataConversionExtensions.DateTime(Wyam.Common.Meta.IMetadata,System.String,System.DateTime). This method never throws an exception. It will return the specified default value if the key is not found.
DirectoryPath(string, DirectoryPath) DirectoryPath
Gets the value for the specified key converted to a Wyam.Common.Meta.MetadataConversionExtensions.DirectoryPath(Wyam.Common.Meta.IMetadata,System.String,Wyam.Common.IO.DirectoryPath). This method never throws an exception. It will return the specified default value if the key is not found or if the string value can't be converted to a Wyam.Common.Meta.MetadataConversionExtensions.DirectoryPath(Wyam.Common.Meta.IMetadata,System.String,Wyam.Common.IO.DirectoryPath).
Document(string, IDocument) IDocument
Gets the value for the specified key converted to a Wyam.Common.Documents.IDocument. This method never throws an exception. It will return null if the key is not found.
DocumentList(string, IReadOnlyList<IDocument>) IReadOnlyList<T>
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 Wyam.Common.Documents.IDocument.
Dynamic(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.
FilePath(string, FilePath) FilePath
Gets the value for the specified key converted to a Wyam.Common.Meta.MetadataConversionExtensions.FilePath(Wyam.Common.Meta.IMetadata,System.String,Wyam.Common.IO.FilePath). This method never throws an exception. It will return the specified default value if the key is not found or if the string value can't be converted to a Wyam.Common.Meta.MetadataConversionExtensions.FilePath(Wyam.Common.Meta.IMetadata,System.String,Wyam.Common.IO.FilePath).
GroupByMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, TElement>) IEnumerable<T>
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, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, TElement>, IEqualityComparer<TKey>) IEnumerable<T>
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>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>) IEnumerable<T>
Groups the elements of a sequence according to a specified key selector function that returns a sequence of keys.
GroupByMany<KeyValuePair<string, object>, TKey>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, IEqualityComparer<TKey>) IEnumerable<T>
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.
GroupByManyToMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, IEnumerable<TElement>>) IEnumerable<T>
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.
GroupByManyToMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, IEnumerable<TElement>>, IEqualityComparer<TKey>) IEnumerable<T>
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.
List<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.
Name() HtmlString
ParseHtml() IHtmlDocument
Gets an IHtmlDocument by parsing the content of an Wyam.Common.Documents.IDocument.
ParseHtml(HtmlParser) IHtmlDocument
Gets an IHtmlDocument by parsing the content of an Wyam.Common.Documents.IDocument.
String(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.
ToLookupMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, TElement>) 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.
ToLookupMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, TElement>, IEqualityComparer<TKey>) 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.
ToLookupMany<KeyValuePair<string, object>, TKey>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>) ILookup<,>
Creates a lookup from a sequence according to a specified key selector function that returns a sequence of keys.
ToLookupMany<KeyValuePair<string, object>, TKey>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, IEqualityComparer<TKey>) 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.
ToLookupManyToMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, IEnumerable<TElement>>) 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.
ToLookupManyToMany<KeyValuePair<string, object>, TKey, TElement>(Func<KeyValuePair<string, object>, IEnumerable<TKey>>, Func<KeyValuePair<string, object>, IEnumerable<TElement>>, IEqualityComparer<TKey>) 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.
GitHub