Search Results for

    Show / Hide Table of Contents
    View Source

    Class ObservableDictionary<TKey, TValue>

    An ObservableDictionary

    Inheritance
    System.Object
    System.Collections.ObjectModel.Collection<TValue>
    System.Collections.ObjectModel.ObservableCollection<TValue>
    Namespace: Umbraco.Cms.Core.Collections
    Assembly: Umbraco.Core.dll
    Syntax
    public class ObservableDictionary<TKey, TValue> : ObservableCollection<TValue>, IList<TValue>, ICollection<TValue>, IReadOnlyList<TValue>, IReadOnlyCollection<TValue>, IEnumerable<TValue>, IList, ICollection, IEnumerable, INotifyPropertyChanged, INotifyCollectionChanged
    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

    View Source

    ObservableDictionary(Func<TValue, TKey>, Nullable<IEqualityComparer<TKey>>)

    Create new ObservableDictionary

    Declaration
    public ObservableDictionary(Func<TValue, TKey> keySelector, IEqualityComparer<TKey>? equalityComparer = null)
    Parameters
    Type Name Description
    Func<TValue, TKey> keySelector

    Selector function to create key from value

    System.Nullable<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
    Umbraco.Cms.Core.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
    Type Description
    TValue
    View Source

    Keys

    Returns all keys

    Declaration
    public IEnumerable<TKey> Keys { get; }
    Property Value
    Type Description
    IEnumerable<TKey>
    View Source

    KeySelector

    Declaration
    protected Func<TValue, TKey> KeySelector { get; }
    Property Value
    Type Description
    Func<TValue, TKey>
    View Source

    Values

    Returns all values

    Declaration
    public IEnumerable<TValue> Values { get; }
    Property Value
    Type Description
    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

    View Source

    ReplaceAll(IEnumerable<TValue>)

    Declaration
    public void ReplaceAll(IEnumerable<TValue> values)
    Parameters
    Type Name Description
    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
    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • ObservableDictionary(Func<TValue, TKey>, Nullable<IEqualityComparer<TKey>>)
    • Properties
      • Indecies
      • Item[TKey]
      • Keys
      • KeySelector
      • Values
    • Methods
      • ChangeKey(TKey, TKey)
      • ClearCollectionChangedEvents()
      • ClearItems()
      • ContainsKey(TKey)
      • InsertItem(Int32, TValue)
      • Remove(TKey)
      • RemoveItem(Int32)
      • Replace(TKey, TValue)
      • ReplaceAll(IEnumerable<TValue>)
      • TryGetValue(TKey, out TValue)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX