private void OnDictionaryItemRemoved(string key) { if (DictionaryChanged != null) { var eventArgs = NotifyDictionaryChangedEventArgs <string, object> .ForRemoveAction(key); DictionaryChanged(this, eventArgs); } }
private void OnDictionaryReset() { if (DictionaryChanged != null) { var eventArgs = NotifyDictionaryChangedEventArgs <string, object> .ForResetAction(); DictionaryChanged(this, eventArgs); } }
private void OnDictionaryItemChanged(string key, object oldValue, object newValue) { if (DictionaryChanged != null) { var eventArgs = NotifyDictionaryChangedEventArgs <string, object> .ForValueChangedAction(key, oldValue, newValue); DictionaryChanged(this, eventArgs); } }
/// <summary>Removes an item from the instance.</summary> /// <param name="key">The key of the item to remove from the instance.</param> /// <returns><c>true</c> if the item was succesfully removed; otherwise, <c>false</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="key" /> is <c>null</c>.</exception> /// <exception cref="NotSupportedException">The instance is <c>read-only</c>.</exception> public bool Remove(string key) { var removed = _items.Remove(key); if (removed) { OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> .ForRemoveAction(key)); } return(removed); }
/// <summary>Removes an item from the instance.</summary> /// <param name="item">The item to remove from the instance.</param> /// <returns><c>true</c> if the item was succesfully removed; otherwise, <c>false</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="item" />.<see cref="KeyValuePair{TKey, TValue}.Key" /> is <c>null</c>.</exception> /// <exception cref="NotSupportedException">The instance is <c>read-only</c>.</exception> bool ICollection <KeyValuePair <string, object> > .Remove(KeyValuePair <string, object> item) { var removed = _items.Remove(item); if (removed) { OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> .ForRemoveAction(item.Key)); } return(removed); }
/// <summary>Gets or sets the item with the specified <paramref name="key" />.</summary> /// <param name="key">The key of the item to get or set.</param> /// <returns>The item with the specified <paramref name="key" />.</returns> /// <exception cref="ArgumentNullException"><paramref name="key" /> is <c>null</c>.</exception> /// <exception cref="KeyNotFoundException">On <c>get</c>: An item with the specified <paramref name="key" /> could not be found.</exception> /// <exception cref="NotSupportedException">On <c>set</c>: The instance is <c>read-only</c>.</exception> public object this[string key] { get { return(_items[key]); } set { if (_items.ContainsKey(key)) { var oldValue = _items[key]; _items[key] = value; OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> .ForValueChangedAction(key, oldValue, value)); } else { _items[key] = value; OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> .ForAddAction(key)); } } }
/// <summary>Removes all items from the instance.</summary> /// <exception cref="NotSupportedException">The instance is <c>read-only</c>.</exception> public void Clear() { _items.Clear(); OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> .ForResetAction()); }
/// <summary>Adds an item to the instance.</summary> /// <param name="item">The item to add to the instance.</param> /// <exception cref="ArgumentException">An item with the same <paramref name="item" />.<see cref="KeyValuePair{TKey, TValue}.Key" /> already exists in the instance.</exception> /// <exception cref="ArgumentNullException"><paramref name="item" />.<see cref="KeyValuePair{TKey, TValue}.Key" /> is <c>null</c>.</exception> /// <exception cref="NotSupportedException">The instance is <c>read-only</c>.</exception> void ICollection <KeyValuePair <string, object> > .Add(KeyValuePair <string, object> item) { _items.Add(item); OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> .ForAddAction(item.Key)); }
/// <summary>Raises the <see cref="DictionaryChanged" /> event.</summary> /// <param name="eventArgs">The <see cref="NotifyDictionaryChangedEventArgs{TKey, TValue}" /> for the event.</param> private void OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> eventArgs) { DictionaryChanged?.Invoke(this, eventArgs); }
/// <summary>Adds an item to the instance.</summary> /// <param name="key">The key of the item to add to the instance.</param> /// <param name="value">The value of the item to add to the instance.</param> /// <exception cref="ArgumentException">An item with the same <paramref name="key" /> already exists in the instance.</exception> /// <exception cref="ArgumentNullException"><paramref name="key" /> is <c>null</c>.</exception> /// <exception cref="NotSupportedException">The instance is <c>read-only</c>.</exception> public void Add(string key, object value) { _items.Add(key, value); OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> .ForAddAction(key)); }