Class ObservableDictionary<TKey, TValue>
An ObservableDictionary
Inheritance
System.Object
System.Collections.ObjectModel.Collection<TValue>
System.Collections.ObjectModel.ObservableCollection<TValue>
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public class ObservableDictionary<TKey, TValue> : ObservableCollection<TValue>, IList<TValue>, ICollection<TValue>, IList, ICollection, IReadOnlyList<TValue>, IReadOnlyCollection<TValue>, IEnumerable<TValue>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Type Parameters
Name | Description |
---|---|
TKey | The type of the indexing key |
TValue | The type of elements contained in the BindableCollection |
Remarks
Assumes that the key will not change and is unique for each element in the collection. Collection is not thread-safe, so calls should be made single-threaded.
Constructors
ObservableDictionary(Func<TValue, TKey>)
Create new ObservableDictionary
Declaration
public ObservableDictionary(Func<TValue, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TValue, TKey> | keySelector | Selector function to create key from value |
Fields
Indecies
Declaration
protected Dictionary<TKey, int> Indecies
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<TKey, System.Int32> |
KeySelector
Declaration
protected Func<TValue, TKey> KeySelector
Field Value
Type | Description |
---|---|
System.Func<TValue, TKey> |
Properties
Item[TKey]
Gets or sets the element with the specified key. If setting a new value, new value must have same key.
Declaration
public virtual TValue this[TKey key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
TKey | key | Key of element to replace |
Property Value
Type | Description |
---|---|
TValue |
Methods
ChangeKey(TKey, TKey)
Allows us to change the key of an item
Declaration
public virtual void ChangeKey(TKey currentKey, TKey newKey)
Parameters
Type | Name | Description |
---|---|---|
TKey | currentKey | |
TKey | newKey |
ClearItems()
Declaration
protected override void ClearItems()
ContainsKey(TKey)
Declaration
public virtual bool ContainsKey(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key |
Returns
Type | Description |
---|---|
System.Boolean |
InsertItem(Int32, TValue)
Declaration
protected override void InsertItem(int index, TValue item)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | |
TValue | item |
Remove(TKey)
Declaration
public virtual bool Remove(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key |
Returns
Type | Description |
---|---|
System.Boolean |
RemoveItem(Int32)
Declaration
protected override void RemoveItem(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Replace(TKey, TValue)
Replaces element at given key with new value. New value must have same key.
Declaration
public virtual bool Replace(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | Key of element to replace |
TValue | value | New value |
Returns
Type | Description |
---|---|
System.Boolean | False if key not found |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException |