Class SwiftObservableDictionary<TKey, TValue>
- Namespace
- SwiftCollections.Observable
- Assembly
- SwiftCollections.dll
Represents a dictionary that notifies listeners of changes to its items and structure.
[JsonConverter(typeof(StateJsonConverterFactory))]
[MemoryPackable(GenerateType.Object)]
public class SwiftObservableDictionary<TKey, TValue> : SwiftDictionary<TKey, TValue>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable, IMemoryPackable<SwiftDictionary<TKey, TValue>>, IStateBacked<SwiftDictionaryState<TKey, TValue>>, INotifyPropertyChanged, INotifyCollectionChanged, IMemoryPackable<SwiftObservableDictionary<TKey, TValue>>, IMemoryPackFormatterRegister where TKey : notnull
Type Parameters
TKeyThe type of keys in the dictionary.
TValueThe type of values in the dictionary.
- Inheritance
-
SwiftDictionary<TKey, TValue>SwiftObservableDictionary<TKey, TValue>
- Implements
-
IDictionary<TKey, TValue>ICollection<KeyValuePair<TKey, TValue>>IEnumerable<KeyValuePair<TKey, TValue>>IMemoryPackable<SwiftDictionary<TKey, TValue>>IStateBacked<SwiftDictionaryState<TKey, TValue>>IMemoryPackable<SwiftObservableDictionary<TKey, TValue>>IMemoryPackFormatterRegister
- Inherited Members
- Extension Methods
Remarks
MemoryPack GenerateType: Object
SwiftCollections.SwiftDictionaryState<TKey, TValue> State
Constructors
SwiftObservableDictionary()
Initializes a new instance of the SwiftObservableDictionary class.
public SwiftObservableDictionary()
SwiftObservableDictionary(SwiftDictionaryState<TKey, TValue>)
Initializes a new instance of the SwiftObservableDictionary<TKey, TValue> class with the specified SwiftDictionaryState<TKey, TValue>.
[MemoryPackConstructor]
public SwiftObservableDictionary(SwiftDictionaryState<TKey, TValue> state)
Parameters
stateSwiftDictionaryState<TKey, TValue>The state containing the internal array, count, offset, and version for initialization.
Properties
this[TKey]
Gets or sets the value associated with the specified key. Raises property and collection change notifications.
[JsonIgnore]
[MemoryPackIgnore]
public TValue this[TKey key] { get; set; }
Parameters
keyTKey
Property Value
- TValue
Methods
Add(TKey, TValue)
Adds an element with the provided key and value to the dictionary. Raises a collection change notification.
public override bool Add(TKey key, TValue value)
Parameters
keyTKeyvalueTValue
Returns
Clear()
Clears all elements from the dictionary. Raises a reset collection change notification.
public override void Clear()
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Raises the CollectionChanged event for the specified action and items.
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
Parameters
OnPropertyChanged(string)
Raises the PropertyChanged event.
protected virtual void OnPropertyChanged(string propertyName)
Parameters
propertyNamestringThe name of the property that changed.
Remove(TKey)
Removes the element with the specified key from the dictionary. Raises a collection change notification if the key existed.
public override bool Remove(TKey key)
Parameters
keyTKey
Returns
Events
CollectionChanged
Raised when the dictionary's collection is modified.
public event NotifyCollectionChangedEventHandler? CollectionChanged
Event Type
PropertyChanged
Raised when a property on the dictionary changes.
public event PropertyChangedEventHandler? PropertyChanged