Class PropertyDictionary
- Namespace
- Excalibur.Dispatch.Serialization
- Assembly
- Excalibur.Dispatch.Abstractions.dll
Adapts an IDictionary<TKey, TValue> of object values to expose nullable values as required by IMessageContext.
public sealed class PropertyDictionary : IDictionary<string, object?>, ICollection<KeyValuePair<string, object?>>, IEnumerable<KeyValuePair<string, object?>>, IEnumerable
- Inheritance
-
PropertyDictionary
- Implements
- Inherited Members
- Extension Methods
Remarks
Initializes a new instance of the PropertyDictionary class.
Constructors
PropertyDictionary(IDictionary<string, object>)
Adapts an IDictionary<TKey, TValue> of object values to expose nullable values as required by IMessageContext.
public PropertyDictionary(IDictionary<string, object> items)
Parameters
itemsIDictionary<string, object>The underlying dictionary to adapt.
Remarks
Initializes a new instance of the PropertyDictionary class.
Properties
Count
Gets the number of elements in the dictionary.
public int Count { get; }
Property Value
IsReadOnly
Gets a value indicating whether the dictionary is read-only.
public bool IsReadOnly { get; }
Property Value
- bool
The current IsReadOnly value.
this[string]
Gets or sets the element with the specified key.
public object? this[string key] { get; set; }
Parameters
keystringThe key of the element to get or set.
Property Value
- object
The element with the specified key, or null if the key does not exist.
Keys
Gets a collection containing the keys in the dictionary.
public ICollection<string> Keys { get; }
Property Value
- ICollection<string>
The current Keys value.
Values
Gets a collection containing the values in the dictionary.
public ICollection<object?> Values { get; }
Property Value
Methods
Add(KeyValuePair<string, object?>)
Adds the specified key-value pair to the dictionary. When the value is null, the key is removed instead (consistent with ASP.NET Core route value semantics).
public void Add(KeyValuePair<string, object?> item)
Parameters
itemKeyValuePair<string, object>The key-value pair to add.
Add(string, object?)
Adds an element with the specified key and value to the dictionary.
When value is null, the key is removed instead
(consistent with ASP.NET Core route value semantics).
public void Add(string key, object? value)
Parameters
keystringThe key of the element to add.
valueobjectThe value of the element to add, or null to remove the key.
Clear()
Removes all elements from the dictionary.
public void Clear()
Contains(KeyValuePair<string, object?>)
Determines whether the dictionary contains a specific key-value pair.
public bool Contains(KeyValuePair<string, object?> item)
Parameters
itemKeyValuePair<string, object>The key-value pair to locate.
Returns
- bool
true if the key-value pair is found; otherwise, false.
ContainsKey(string)
Determines whether the dictionary contains the specified key.
public bool ContainsKey(string key)
Parameters
keystringThe key to locate.
Returns
- bool
true if the dictionary contains an element with the specified key; otherwise, false.
CopyTo(KeyValuePair<string, object?>[], int)
Copies the elements of the dictionary to an array, starting at the specified array index.
public void CopyTo(KeyValuePair<string, object?>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<string, object>[]The destination array.
arrayIndexintThe zero-based index in the array at which copying begins.
Exceptions
- ArgumentNullException
Thrown when
arrayis null.- ArgumentOutOfRangeException
Thrown when
arrayIndexis negative.- ArgumentException
Thrown when the destination array is not large enough.
GetEnumerator()
Returns an enumerator that iterates through the dictionary.
public IEnumerator<KeyValuePair<string, object?>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<string, object>>
An enumerator for the dictionary.
Remove(KeyValuePair<string, object?>)
Removes the specified key-value pair from the dictionary.
public bool Remove(KeyValuePair<string, object?> item)
Parameters
itemKeyValuePair<string, object>The key-value pair to remove.
Returns
- bool
true if the key-value pair was successfully removed; otherwise, false.
Remove(string)
Removes the element with the specified key from the dictionary.
public bool Remove(string key)
Parameters
keystringThe key of the element to remove.
Returns
- bool
true if the element was successfully removed; otherwise, false.
TryGetValue(string, out object?)
Gets the value associated with the specified key.
public bool TryGetValue(string key, out object? value)
Parameters
keystringThe key of the value to get.
valueobjectWhen this method returns, contains the value associated with the specified key, if found; otherwise, null.
Returns
- bool
true if the dictionary contains an element with the specified key; otherwise, false.