Search Results for

    Show / Hide Table of Contents
    View Source

    Class ObservableDictionary<TKey, TValue>

    An ObservableDictionary

    Inheritance
    object
    Collection<TValue>
    ObservableCollection<TValue>
    Namespace: Umbraco.Cms.Core.Collections
    Assembly: Umbraco.Core.dll
    Syntax
    public class ObservableDictionary<TKey, TValue> : ObservableCollection<TValue> where TKey : notnull
    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>, 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

    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
    Dictionary<TKey, int>
    View Source

    this[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

    KeySelector

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

    Keys

    Returns all keys

    Declaration
    public IEnumerable<TKey> Keys { get; }
    Property Value
    Type Description
    IEnumerable<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 System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged event handlers

    Declaration
    public void ClearCollectionChangedEvents()
    View Source

    ClearItems()

    Removes all items from the collection.

    Declaration
    protected override void ClearItems()
    View Source

    ContainsKey(TKey)

    Determines whether the read-only dictionary contains an element that has the specified key.

    Declaration
    public bool ContainsKey(TKey key)
    Parameters
    Type Name Description
    TKey key

    The key to locate.

    Returns
    Type Description
    bool

    true if the read-only dictionary contains an element that has the specified key; otherwise, false.

    Exceptions
    Type Condition
    ArgumentNullException

    key is null.

    View Source

    InsertItem(int, TValue)

    Inserts an item into the collection at the specified index.

    Declaration
    protected override void InsertItem(int index, TValue item)
    Parameters
    Type Name Description
    int index

    The zero-based index at which item should be inserted.

    TValue item

    The object to insert.

    View Source

    Remove(TKey)

    Removes the element with the specified key from the System.Collections.Generic.IDictionary<TKey, TValue>.

    Declaration
    public bool Remove(TKey key)
    Parameters
    Type Name Description
    TKey key

    The key of the element to remove.

    Returns
    Type Description
    bool

    true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original System.Collections.Generic.IDictionary<TKey, TValue>.

    Exceptions
    Type Condition
    ArgumentNullException

    key is null.

    NotSupportedException

    The System.Collections.Generic.IDictionary<TKey, TValue> is read-only.

    View Source

    RemoveItem(int)

    Removes the item at the specified index of the collection.

    Declaration
    protected override void RemoveItem(int index)
    Parameters
    Type Name Description
    int index

    The zero-based index of the element to remove.

    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
    bool

    False if key not found

    Exceptions
    Type Condition
    InvalidOperationException
    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)

    Gets the value that is associated with the specified key.

    Declaration
    public bool TryGetValue(TKey key, out TValue val)
    Parameters
    Type Name Description
    TKey key

    The key to locate.

    TValue val
    Returns
    Type Description
    bool

    true if the object that implements the System.Collections.Generic.IReadOnlyDictionary<TKey, TValue> interface contains an element that has the specified key; otherwise, false.

    Exceptions
    Type Condition
    ArgumentNullException

    key is null.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX