[]
        
(Showing Draft Content)

GrapeCity.Documents.Common.ObservableDictionary-2

Class ObservableDictionary<TKey, TValue>

Namespace
GrapeCity.Documents.Common
Assembly
GcDocs.Imaging.dll
public class ObservableDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IDictionary, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IList, ICollection, IEnumerable

Type Parameters

TKey

The type of the keys in the dictionary.

TValue

The type of the values in the dictionary.

Inheritance
ObservableDictionary<TKey, TValue>
Implements
IDictionary<TKey, TValue>
ICollection<KeyValuePair<TKey, TValue>>
IReadOnlyDictionary<TKey, TValue>
IEnumerable<KeyValuePair<TKey, TValue>>
Inherited Members

Constructors

ObservableDictionary()

Initializes a new instance of the ObservableDictionary<TKey, TValue> class.

public ObservableDictionary()

ObservableDictionary(IEqualityComparer<TKey>)

Initializes a new instance of the ObservableDictionary<TKey, TValue> class.

public ObservableDictionary(IEqualityComparer<TKey> comparer)

Parameters

comparer IEqualityComparer<TKey>

Fields

m_Items

The underlying Dictionary<TKey, TValue>.

protected readonly Dictionary<TKey, TValue> m_Items

Field Value

Dictionary<TKey, TValue>

Properties

Changed

Gets a value indicating whether the list was changed.

public bool Changed { get; set; }

Property Value

bool

Count

Gets the number of key/value pairs contained in the SortedDictionary<TKey, TValue>.

public int Count { get; }

Property Value

int

this[TKey]

Gets or sets the value associated with the specified key.

public TValue this[TKey key] { get; set; }

Parameters

key TKey

The key of the value to get or set.

Property Value

TValue

Keys

Gets a collection containing the keys in the ObservableSortedDictionary<TKey, TValue>.

public ICollection<TKey> Keys { get; }

Property Value

ICollection<TKey>

Values

Gets a collection containing the values in the SortedDictionary<TKey, TValue>.

public ICollection<TValue> Values { get; }

Property Value

ICollection<TValue>

Methods

Add(TKey, TValue)

Adds an element with the specified key and value into the ObservableSortedDictionary<TKey, TValue>.

public void Add(TKey key, TValue value)

Parameters

key TKey

The key of the element to add.

value TValue

The value of the element to add. The value can be null for reference types.

AddItem(TKey, TValue)

Adds an element into collection with specified key.

protected virtual void AddItem(TKey key, TValue value)

Parameters

key TKey
value TValue

Clear()

Removes all elements from the ObservableSortedDictionary<TKey, TValue>.

public void Clear()

ClearItems()

Removes all elements from the collection.

protected virtual void ClearItems()

ContainsKey(TKey)

Determines whether the ObservableSortedDictionary<TKey, TValue> contains an element with the specified key.

public bool ContainsKey(TKey key)

Parameters

key TKey

The key to locate in the ObservableSortedDictionary<TKey, TValue>.

Returns

bool

OnChanged()

Called when dictionary was changed, sets Changed to true.

protected virtual void OnChanged()

Remove(TKey)

Removes the element with the specified key from the ObservableSortedDictionary<TKey, TValue>.

public bool Remove(TKey key)

Parameters

key TKey

The key of the element to remove.

Returns

bool

RemoveItem(TKey)

Removes an element with specified key.

protected virtual bool RemoveItem(TKey key)

Parameters

key TKey

Returns

bool

SetItem(TKey, TValue)

Replaces the element with the specified key.

protected virtual void SetItem(TKey key, TValue value)

Parameters

key TKey
value TValue

TryGetValue(TKey, out TValue)

Gets the value associated with the specified key.

public bool TryGetValue(TKey key, out TValue value)

Parameters

key TKey

The key of the value to get.

value TValue

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter.

Returns

bool

true if the ObservableSortedDictionary<TKey, TValue> contains an element with the specified key; otherwise, false.

Events

DictionaryChanged

Raised when the ObservableDictionary<TKey, TValue> is changed.

public event EventHandler DictionaryChanged

Event Type

EventHandler