Esempio n. 1
0
 /// <summary>
 /// Adds an item or updates it if an item with that key already exists in the collection.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <param name="updator">The updator.</param>
 /// <remarks></remarks>
 public virtual void AddOrUpdate(TKey key, Lazy <TValue> value, Func <TKey, Lazy <TValue>, Lazy <TValue> > updator)
 {
     if (Inner.ContainsKey(key))
     {
         Inner[key] = updator(key, Inner[key]);
     }
     else
     {
         Inner.Add(key, value);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Adds an element with the provided key and value loader to the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="valueLoader">The value loader.</param>
 /// <remarks></remarks>
 public virtual void Add(TKey key, Lazy <TValue> valueLoader)
 {
     if (Inner.ContainsKey(key))
     {
         throw new ArgumentException("An element with the same key already exists");
     }
     else
     {
         Inner.Add(key, valueLoader);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>.
 /// </summary>
 /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param><exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.</exception>
 public virtual void Add(KeyValuePair <TKey, TValue> item)
 {
     EnsureLazyLoaderCalled();
     if (Inner.ContainsKey(item.Key))
     {
         throw new ArgumentException("An element with the same key already exists");
     }
     else
     {
         Inner.Add(item.Key, new Lazy <TValue>(() => item.Value));
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Adds an item or updates it if an item with that key already exists in the collection.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <param name="updator">The updator.</param>
 /// <remarks></remarks>
 public virtual void AddOrUpdate(TKey key, TValue value, Func <TKey, TValue, TValue> updator)
 {
     if (Inner.ContainsKey(key))
     {
         Inner[key] = updator(key, Inner[key]);
         OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, value));
     }
     else
     {
         Inner.Add(key, value);
         OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, value));
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the specified key.
 /// </summary>
 /// <returns>
 /// true if the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the key; otherwise, false.
 /// </returns>
 /// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.</param><exception cref="T:System.ArgumentNullException"><paramref name="key"/> is null.</exception>
 public bool ContainsKey(TKey key)
 {
     EnsureLazyLoaderCalled();
     return(Inner.ContainsKey(key));
 }
Esempio n. 6
0
 /// <summary>
 /// Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the specified key.
 /// </summary>
 /// <returns>
 /// true if the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the key; otherwise, false.
 /// </returns>
 /// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.</param><exception cref="T:System.ArgumentNullException"><paramref name="key"/> is null.</exception>
 public bool ContainsKey(TKey key)
 {
     return(Inner.ContainsKey(key));
 }
Esempio n. 7
0
 public bool ContainsKey(string key)
 {
     return(Inner.ContainsKey(key));
 }