MetadataDictionary Class
Definition
Provides a default implementation of the IMetadataDictionary interface. This class cannot be inherited.
public sealed class MetadataDictionary : IMetadataDictionary, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
- Inheritance
-
MetadataDictionary
- Implements
Examples
This example shows how to store reserved metadata keys and custom values in a case-insensitive metadata dictionary.
using Savvyio;
namespace ExampleApp;
public sealed class MetadataDictionaryExample
{
public bool HasCorrelationId()
{
var metadata = new MetadataDictionary { ["correlationid"] = "corr-42", ["tenant"] = "north-europe" };
return metadata.ContainsKey(MetadataDictionary.CorrelationId) && metadata["tenant"].ToString() == "north-europe";
}
}
Constructors
| Name | Description |
|---|---|
| MetadataDictionary() | Initializes a new instance of the MetadataDictionary class. |
Fields
| Name | Description |
|---|---|
| AggregateVersion | AggregateVersion is a reserved keyword. |
| CausationId | CausationId is a reserved keyword. |
| CorrelationId | CorrelationId is a reserved keyword. |
| EventId | EventId is a reserved keyword. |
| MemberType | MemberType is a reserved keyword. |
| RequestId | RequestId is a reserved keyword. |
| Timestamp | Timestamp is a reserved keyword. |
Properties
| Name | Description |
|---|---|
| Count | Gets the number of elements contained in the MetadataDictionary. |
| IsReadOnly | Gets a value indicating whether the MetadataDictionaryis read-only. |
| this[string] | Gets or sets the element with the specified key. |
| Keys | Gets an ICollection<T> containing the keys of the MetadataDictionary. |
| ReservedKeywords | Gets a list of the reserved keywords. |
| Values | Gets an ICollection<T> containing the values in the MetadataDictionary. |
Methods
| Name | Description |
|---|---|
| Add(KeyValuePair<string, object>) | Adds an item to the MetadataDictionary. |
| Add(string, object) | Adds an element with the provided key and value to the MetadataDictionary. |
| Clear() | Removes all items from the MetadataDictionary. |
| Contains(KeyValuePair<string, object>) | Determines whether the MetadataDictionary contains a specific value. |
| ContainsKey(string) | Determines whether the MetadataDictionary contains an element with the specified key. |
| CopyTo(KeyValuePair<string, object>[], int) | Copies the elements of the MetadataDictionary to an array of type KeyValuePair<TKey, TValue>, starting at the specified array index. |
| GetEnumerator() | Returns an enumerator that iterates through the collection. |
| Remove(KeyValuePair<string, object>) | Removes the first occurrence of a specific object from the MetadataDictionary. |
| Remove(string) | Removes the element with the specified key from the MetadataDictionary. |
| TryGetValue(string, out object) | Gets the value associated with the specified key. |