IMetadata Interface

Summary

Contains a set of metadata with flexible runtime conversion methods. Metadata keys are case-insensitive.
graph BT Type-.->Interface0["IReadOnlyDictionary<string, Object>"] Type["IMetadata"] class Type type-node Implementing0["IReadOnlySettings"]-.->Type click Implementing0 "/api/Wyam.Common.Configuration/IReadOnlySettings" Implementing1["CustomDocument"]-.->Type click Implementing1 "/api/Wyam.Core.Documents/CustomDocument" Implementing2["IExecutionContext"]-.->Type click Implementing2 "/api/Wyam.Common.Execution/IExecutionContext" Implementing3["TestDocument"]-.->Type click Implementing3 "/api/Wyam.Testing.Documents/TestDocument" Implementing4["ISettings"]-.->Type click Implementing4 "/api/Wyam.Common.Configuration/ISettings" Implementing5["TestSettings"]-.->Type click Implementing5 "/api/Wyam.Testing.Configuration/TestSettings" Implementing6["ConvertingDictionary"]-.->Type click Implementing6 "/api/Wyam.Common.Meta/ConvertingDictionary" Implementing7["TestMetadata"]-.->Type click Implementing7 "/api/Wyam.Testing.Meta/TestMetadata" Implementing8["IMetadataDictionary"]-.->Type click Implementing8 "/api/Wyam.Common.Meta/IMetadataDictionary" Implementing9["IDocument"]-.->Type click Implementing9 "/api/Wyam.Common.Documents/IDocument" Implementing10["TestExecutionContext"]-.->Type click Implementing10 "/api/Wyam.Testing.Execution/TestExecutionContext"

Syntax

public interface IMetadata : IReadOnlyDictionary<string, Object>

Methods

Name Value Summary
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.
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 or the value cannot be converted to T.
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.
GetMetadata(string[]) IMetadata
Gets a new Wyam.Common.Meta.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.
GetRaw(string) Object
Gets the raw value for the specified key. This method will not materialize Wyam.Common.Meta.IMetadataValue values the way Wyam.Common.Meta.IMetadata.Get(System.String,System.Object) will. A System.Collections.Generic.KeyNotFoundException will be thrown for missing keys.
MetadataAs<T>() IMetadata<T>
Presents metadata values as a specific type (see Wyam.Common.Meta.IMetadata).
TryGetValue<T>(string, T) bool
Tries to get the value for the specified key.

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<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 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).
List<T>(string, IReadOnlyList<T>) IReadOnlyList<T>
Gets the value for the specified key converted to a System.Collections.Generic.IReadOnlyList`1. 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
String(string, Func<string, string>, string) string
Formats a string value if it exists in the metadata, otherwise returns a default value.
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.
XAttribute(string) XAttribute
Gets an XML attribute for the given metadata key. The name of the attribute will be the lower-case key name.
XAttribute(string, Func<string, string>) XAttribute
XAttribute(string, Func<string, XAttribute>) XAttribute
XAttribute(string, string) XAttribute
Gets an XML attribute for the given metadata key.
XAttribute(string, string, Func<string, string>) XAttribute
XElement(string, Func<string, Object[]>) XElement
XElement(string, Func<string, XElement>) XElement
XElement(string, string, Func<string, Object[]>) XElement
GitHub