Esempio n. 1
0
        private void OnDictionaryItemAdded(string key)
        {
            if (DictionaryChanged != null)
            {
                var eventArgs = NotifyDictionaryChangedEventArgs <string, object> .ForAddAction(key);

                DictionaryChanged(this, eventArgs);
            }
        }
Esempio n. 2
0
        /// <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));
                }
            }
        }
Esempio n. 3
0
 /// <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));
 }
Esempio n. 4
0
 /// <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));
 }