Table of Contents

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

TKey

The type of keys in the dictionary.

TValue

The 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

state SwiftDictionaryState<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

key TKey

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

key TKey
value TValue

Returns

bool

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

args NotifyCollectionChangedEventArgs

OnPropertyChanged(string)

Raises the PropertyChanged event.

protected virtual void OnPropertyChanged(string propertyName)

Parameters

propertyName string

The 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

key TKey

Returns

bool

Events

CollectionChanged

Raised when the dictionary's collection is modified.

public event NotifyCollectionChangedEventHandler? CollectionChanged

Event Type

NotifyCollectionChangedEventHandler

PropertyChanged

Raised when a property on the dictionary changes.

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler