Beispiel #1
0
        public void Add(TKey key, TValue value)
        {
            ThrowHelper.ThrowIfArgumentNullException(key, "key");
            ThrowIfKeyExists(key);

            dict.Add(key, value);
        }
Beispiel #2
0
        object IDictionary.this[object key]
        {
            get
            {
                ThrowHelper.ThrowIfArgumentNullException(key, "key");
                if (!(key is TKey))
                {
                    return(null);
                }
                TValue val;

                if (!TryGetValue((TKey)key, out val))
                {
                    return(null);
                }

                return(val);
            }
            set
            {
                ThrowHelper.ThrowIfArgumentNullException(key, "key");
                ThrowIfWrongKeyType(key);
                ThrowIfWrongValueType(value);
                this[(TKey)key] = (TValue)value;
            }
        }
Beispiel #3
0
        public bool Remove(KeyValuePair <TKey, TValue> item)
        {
            ThrowHelper.ThrowIfArgumentNullException(item, "item");
            ThrowHelper.ThrowIfArgumentNullException(item.Key, "item.Key");

            return(dict.Remove(item));
        }
Beispiel #4
0
        void IDictionary.Add(object key, object value)
        {
            ThrowHelper.ThrowIfArgumentNullException(key, "key");
            ThrowIfWrongKeyType(key);
            ThrowIfWrongValueType(value);

            Add((TKey)key, (TValue)value);
        }
Beispiel #5
0
 void IDictionary.Remove(object key)
 {
     ThrowHelper.ThrowIfArgumentNullException(key, "key");
     if (!(key is TKey))
     {
         return;
     }
     Remove((TKey)key);
 }
Beispiel #6
0
 bool IDictionary.Contains(object key)
 {
     ThrowHelper.ThrowIfArgumentNullException(key, "key");
     if (!(key is TKey))
     {
         return(false);
     }
     return(ContainsKey((TKey)key));
 }
Beispiel #7
0
 public TValue this[TKey key]
 {
     get
     {
         ThrowHelper.ThrowIfArgumentNullException(key, "key");
         return(dict[key]);
     }
     set
     {
         ThrowHelper.ThrowIfArgumentNullException(key, "key");
         dict[key] = value;
     }
 }
Beispiel #8
0
 public bool TryGetValue(TKey key, out TValue value)
 {
     ThrowHelper.ThrowIfArgumentNullException(key, "key");
     return(dict.TryGetValue(key, out value));
 }
Beispiel #9
0
 public bool Remove(TKey key)
 {
     ThrowHelper.ThrowIfArgumentNullException(key, "key");
     return(dict.Remove(key));
 }
Beispiel #10
0
 public bool ContainsKey(TKey key)
 {
     ThrowHelper.ThrowIfArgumentNullException(key, "key");
     return(dict.ContainsKey(key));
 }
Beispiel #11
0
 public void Add(KeyValuePair <TKey, TValue> item)
 {
     ThrowHelper.ThrowIfArgumentNullException(item, "item");
     ThrowIfKeyExists(item.Key);
     dict.Add(item);
 }