IMetadataConversionExtensions Class
Extensions to make it easier to get typed information from metadata.
Namespace
Statiq.Common
Base Types
  • object
graph BT Type-->Base0["object"] Type["IMetadataConversionExtensions"] class Type type-node

Syntax

public static class IMetadataConversionExtensions

Methods

Name Return Value Summary
GetBool(IMetadata, 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.
static
GetDateTime(IMetadata, 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.
static
GetDateTimeOffset(IMetadata, 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.
static
GetDocument(IMetadata, 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.
static
GetDocumentList(IMetadata, 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.
static
GetDocumentList<TDocument>(IMetadata, 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.
static
GetDocuments(IMetadata, 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.
static
GetDocuments<TDocument>(IMetadata, 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.
static
GetDynamic(IMetadata, 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.
static
GetInt(IMetadata, 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.
static
GetList<T>(IMetadata, 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.
static
GetMetadata(IMetadata, 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.
static
GetPath(IMetadata, 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.
static
GetString(IMetadata, string, Func<string, string>, string) string
Formats a string value if it exists in the metadata, otherwise returns a default value.
static
GetString(IMetadata, 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.
static