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>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)); } } }