IMetadata Interface

Summary

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

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 KeyNotFoundException will be thrown for missing keys.
MetadataAs<T>() IMetadata<T>
Presents metadata values as a specific type (see Wyam.Common.Meta.IMetadata).

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,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<>) IReadOnlyList<>
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<>) 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.
Name() HtmlString
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.
GitHub