ConvertingDictionary Class

Summary

A dictionary with metadata type conversion superpowers.
Assembly
Wyam.Common.dll
Namespace
Wyam.Common.Meta
Interfaces
Base Types
  • Object
graph BT Type-->Base0["Object"] Type-.->Interface0["IMetadataDictionary"] click Interface0 "/api/Wyam.Common.Meta/IMetadataDictionary" Type-.->Interface1["IDictionary<string, Object>"] Type-.->Interface2["IMetadata"] click Interface2 "/api/Wyam.Common.Meta/IMetadata" Type-.->Interface3["IReadOnlyDictionary<string, Object>"] Type["ConvertingDictionary"] class Type type-node

Syntax

public class ConvertingDictionary : IMetadataDictionary, IDictionary<string, Object>, IMetadata, 
    IReadOnlyDictionary<string, Object>

Remarks

This class wraps an underlying System.Collections.Generic.Dictionary`2 but uses the provided Wyam.Common.Execution.IExecutionContext to perform type conversions when requesting values.

Constructors

Properties

Name Value Summary
Count int
The count of metadata.
IsReadOnly bool
Keys ICollection<string>
A collection of keys in the metadata.
this[string] Object
Gets a metadata value given the specified metadata key.
Values ICollection<Object>
A collection of values in the metadata.

Methods

Name Value Summary
Add(KeyValuePair<string, Object>) void
Add(string, Object) void
Clear() void
Contains(KeyValuePair<string, Object>) bool
ContainsKey(string) bool
Whether or not the metadata contains the specified key.
CopyTo(KeyValuePair<string, Object>[], int) void
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.
GetEnumerator() IEnumerator<KeyValuePair<string, Object>>
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).
Remove(KeyValuePair<string, Object>) bool
Remove(string) bool
TryGetValue(string, Object) bool
Attempts to get a value from metadata.
TryGetValue<T>(string, T) bool
Tries to get the value for the specified key.
GitHub