View Source
Class ObservableDictionary<TKey, TValue>
Inheritance
System.Object
System.Collections.ObjectModel.Collection<TValue>
System.Collections.ObjectModel.ObservableCollection<TValue>
Assembly: Umbraco.Core.dll
Syntax
public class ObservableDictionary<TKey, TValue> : ObservableCollection<TValue>, IList<TValue>, ICollection<TValue>, IList, ICollection, IReadOnlyList<TValue>, IReadOnlyCollection<TValue>, IEnumerable<TValue>, INotifyPropertyChanged, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, INotifyCollectionChanged
Type Parameters
Name |
Description |
TKey |
The type of the indexing key
|
TValue |
The type of elements contained in the BindableCollection
|
Constructors
View Source
ObservableDictionary(Func<TValue, TKey>, IEqualityComparer<TKey>)
Create new ObservableDictionary
Declaration
public ObservableDictionary(Func<TValue, TKey> keySelector, IEqualityComparer<TKey> equalityComparer = null)
Parameters
Type |
Name |
Description |
System.Func<TValue, TKey> |
keySelector |
Selector function to create key from value
|
System.Collections.Generic.IEqualityComparer<TKey> |
equalityComparer |
The equality comparer to use when comparing keys, or null to use the default comparer.
|
Properties
View Source
Indecies
Declaration
protected Dictionary<TKey, int> Indecies { get; }
Property Value
Type |
Description |
System.Collections.Generic.Dictionary<TKey, System.Int32> |
|
View Source
Item[TKey]
Gets or sets the element with the specified key. If setting a new value, new value must have same key.
Declaration
public TValue this[TKey key] { get; set; }
Parameters
Type |
Name |
Description |
TKey |
key |
Key of element to replace
|
Property Value
View Source
Keys
Declaration
public IEnumerable<TKey> Keys { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<TKey> |
|
View Source
KeySelector
Declaration
protected Func<TValue, TKey> KeySelector { get; }
Property Value
Type |
Description |
System.Func<TValue, TKey> |
|
View Source
Values
Declaration
public IEnumerable<TValue> Values { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<TValue> |
|
Methods
View Source
ChangeKey(TKey, TKey)
Allows us to change the key of an item
Declaration
public void ChangeKey(TKey currentKey, TKey newKey)
Parameters
Type |
Name |
Description |
TKey |
currentKey |
|
TKey |
newKey |
|
View Source
ClearCollectionChangedEvents()
Clears all event handlers
Declaration
public void ClearCollectionChangedEvents()
View Source
ClearItems()
Declaration
protected override void ClearItems()
View Source
ContainsKey(TKey)
Declaration
public bool ContainsKey(TKey key)
Parameters
Type |
Name |
Description |
TKey |
key |
|
Returns
Type |
Description |
System.Boolean |
|
View Source
InsertItem(Int32, TValue)
Declaration
protected override void InsertItem(int index, TValue item)
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
TValue |
item |
|
View Source
Remove(TKey)
Declaration
public bool Remove(TKey key)
Parameters
Type |
Name |
Description |
TKey |
key |
|
Returns
Type |
Description |
System.Boolean |
|
View Source
RemoveItem(Int32)
Declaration
protected override void RemoveItem(int index)
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
View Source
Replace(TKey, TValue)
Replaces element at given key with new value. New value must have same key.
Declaration
public 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 |
|
View Source
ReplaceAll(IEnumerable<TValue>)
Declaration
public void ReplaceAll(IEnumerable<TValue> values)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<TValue> |
values |
|
View Source
TryGetValue(TKey, out TValue)
Declaration
public bool TryGetValue(TKey key, out TValue val)
Parameters
Type |
Name |
Description |
TKey |
key |
|
TValue |
val |
|
Returns
Type |
Description |
System.Boolean |
|