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 |
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 |
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 |
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 |
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 |
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 .
static
|
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.
static
|
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 .
static
|
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.
static
|
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.
static
|
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.
static
|
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.
static
|
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.
static
|
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.
static
|
GetString |
string |
Formats a string value if it exists in the metadata, otherwise returns a default value.
static
|
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.
static
|