Class ObservableDictionary<TKey, TValue>
Implements an Observable dictionary of key value pairs..
Inheritance
Implements
Namespace: Cortex.Net.Types
Assembly: Cortex.Net.dll
Syntax
public sealed class ObservableDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IDictionary, IEnumerable<KeyValuePair<TKey, TValue>>, ICollection, IEnumerable, IAtomProvider
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
Constructors
| Improve this Doc View SourceObservableDictionary(ISharedState, IEnhancer, IDictionary<TKey, TValue>, String)
Initializes a new instance of the ObservableDictionary<TKey, TValue> class.
Declaration
public ObservableDictionary(ISharedState sharedState, IEnhancer enhancer, IDictionary<TKey, TValue> initialValues, string name = null)
Parameters
Type | Name | Description |
---|---|---|
ISharedState | sharedState | The ISharedState instance this observableDictionary belongs to. |
IEnhancer | enhancer | The IEnhancer implementation to use. |
IDictionary<TKey, TValue> | initialValues | The initial values. |
System.String | name | The name of the ObservableDictionary. |
ObservableDictionary(ISharedState, IEnhancer, String)
Initializes a new instance of the ObservableDictionary<TKey, TValue> class.
Declaration
public ObservableDictionary(ISharedState sharedState, IEnhancer enhancer, string name = null)
Parameters
Type | Name | Description |
---|---|---|
ISharedState | sharedState | The ISharedState instance this observableDictionary belongs to. |
IEnhancer | enhancer | The IEnhancer implementation to use. |
System.String | name | The name of the ObservableDictionary. |
Properties
| Improve this Doc View SourceCount
Gets the number of elements contained in the ObservableDictionary<TKey, TValue>.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsFixedSize
Gets a value indicating whether the ObservableDictionary<TKey, TValue> has a fixed size.
Declaration
public bool IsFixedSize { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsReadOnly
Gets a value indicating whether the ObservableDictionary<TKey, TValue> is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsSynchronized
Gets a value indicating whether access to the ObservableDictionary<TKey, TValue> is synchronized (thread safe).
Declaration
public bool IsSynchronized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[TKey]
Gets or sets the value associated with the specified key.
Declaration
public TValue this[TKey key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value to get or set. |
Property Value
Type | Description |
---|---|
TValue | The value associated with the specified key. If the specified key is not found, a get operation throws a System.Collections.Generic.KeyNotFoundException, and a set operation creates a new element with the specified key. |
Keys
Gets a collection containing the keys in the ObservableDictionary<TKey, TValue>.
Declaration
public ICollection<TKey> Keys { get; }
Property Value
Type | Description |
---|---|
ICollection<TKey> |
Name
Gets the name of the ObservableDictionary<TKey, TValue>.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
SharedState
Gets the shared state this ObservableDictionary<TKey, TValue> operates on.
Declaration
public ISharedState SharedState { get; }
Property Value
Type | Description |
---|---|
ISharedState |
SyncRoot
Gets an object that can be used to synchronize access to the ObservableDictionary<TKey, TValue>.
Declaration
public object SyncRoot { get; }
Property Value
Type | Description |
---|---|
System.Object |
Values
Gets a collection containing the values in the ObservableDictionary<TKey, TValue>.
Declaration
public ICollection<TValue> Values { get; }
Property Value
Type | Description |
---|---|
ICollection<TValue> |
Methods
| Improve this Doc View SourceAdd(TKey, TValue)
Adds the specified key and value to the dictionary.
Declaration
public void Add(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the element to add. |
TValue | value | The value of the element to add. The value can be null for reference types. |
Add(KeyValuePair<TKey, TValue>)
Adds the specified
Declaration
public void Add(KeyValuePair<TKey, TValue> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue> | item | The pair to add. |
Clear()
Removes all elements from the ObservableDictionary<TKey, TValue>.
Declaration
public void Clear()
Contains(KeyValuePair<TKey, TValue>)
Determines whether the System.Collections.Generic.Dictionary`2 contains the specified key value pair.
Declaration
public bool Contains(KeyValuePair<TKey, TValue> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue> | item | The |
Returns
Type | Description |
---|---|
System.Boolean | true if the System.Collections.Generic.Dictionary`2 contains the key value pair; otherwise, false. |
ContainsKey(TKey)
Determines whether the System.Collections.Generic.Dictionary`2 contains the specified key.
Declaration
public bool ContainsKey(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to locate in the System.Collections.Generic.Dictionary`2. |
Returns
Type | Description |
---|---|
System.Boolean | true if the System.Collections.Generic.Dictionary`2 contains an element with the specified key; otherwise, false. |
CopyTo(KeyValuePair<TKey, TValue>[], Int32)
Copies the elements of the ObservableDictionary<TKey, TValue> to an System.Array, starting at a particular System.Array index.
Declaration
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int index)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue>[] | array | The one-dimensional System.Array that is the destination of the elements copied from ObservableDictionary<TKey, TValue>. The System.Array must have zero-based indexing. |
System.Int32 | index | The zero-based index in array at which copying begins. |
GetEnumerator()
Returns an enumerator that iterates through the ObservableDictionary<TKey, TValue>.
Declaration
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<TKey, TValue>> | An enumerator that can be used to iterate through the ObservableDictionary<TKey, TValue>. |
Remove(TKey)
Removes the value with the specified key from the System.Collections.Generic.Dictionary`2.
Declaration
public bool Remove(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the element to remove. |
Returns
Type | Description |
---|---|
System.Boolean | true if the element is successfully found and removed; otherwise, false. This method returns false if key is not found in the System.Collections.Generic.Dictionary`2. |
Remove(KeyValuePair<TKey, TValue>)
Removes the value with the specified
Declaration
public bool Remove(KeyValuePair<TKey, TValue> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue> | item | The |
Returns
Type | Description |
---|---|
System.Boolean | true if the element is successfully found and removed; otherwise, false. This method returns false if key is not found in the System.Collections.Generic.Dictionary`2. |
TryGetValue(TKey, out TValue)
Gets the value associated with the specified key.
Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key whose value to get. |
TValue | value | 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. This parameter is passed uninitialized. |
Returns
Type | Description |
---|---|
System.Boolean | true if the object that implements System.Collections.Generic.IDictionary`2 contains an element with the specified key; otherwise, false. |
Events
| Improve this Doc View SourceChange
Event that fires before the value will change.
Declaration
public event EventHandler<ObservableDictionaryCancellableEventArgs> Change
Event Type
Type | Description |
---|---|
EventHandler<ObservableDictionaryCancellableEventArgs> |
Changed
Event that fires after the value has changed.
Declaration
public event EventHandler<ObservableDictionaryEventArgs> Changed
Event Type
Type | Description |
---|---|
EventHandler<ObservableDictionaryEventArgs> |
Explicit Interface Implementations
| Improve this Doc View SourceIAtomProvider.Atom
Gets the atom.
Declaration
IAtom IAtomProvider.Atom { get; }
Returns
Type | Description |
---|---|
IAtom |