Exemple #1
0
 void IDictionary.Remove(object key)
 {
     if (Dictionary <TKey, TValue> .IsCompatibleKey(key))
     {
         this.Remove((TKey)key);
     }
 }
 object IDictionary.this[object key]
 {
     get
     {
         if (Dictionary <TKey, TValue> .IsCompatibleKey(key))
         {
             int index = this.FindEntry((TKey)key);
             if (index >= 0)
             {
                 return(this.entries[index].value);
             }
         }
         return(null);
     }
     set
     {
         if (key == null)
         {
             ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
         }
         ThrowHelper.IfNullAndNullsAreIllegalThenThrow <TValue>(value, ExceptionArgument.value);
         try
         {
             TKey local = (TKey)key;
             try
             {
                 this[local] = (TValue)value;
             }
             catch (InvalidCastException)
             {
                 ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(TValue));
             }
         }
         catch (InvalidCastException)
         {
             ThrowHelper.ThrowWrongKeyTypeArgumentException(key, typeof(TKey));
         }
     }
 }
Exemple #3
0
        object IDictionary.this[object key]
        {
            get
            {
                if (Dictionary <TKey, TValue> .IsCompatibleKey(key))
                {
                    int index = this.FindEntry((TKey)key);
                    if (index >= 0)
                    {
                        return(this.entries[index].value);
                    }
                }
                return(null);
            }
            set
            {
                Dictionary <TKey, TValue> .VerifyKey(key);

                Dictionary <TKey, TValue> .VerifyValueType(value);

                this[(TKey)key] = (TValue)value;
            }
        }
Exemple #4
0
 bool IDictionary.Contains(object key)
 {
     return(Dictionary <TKey, TValue> .IsCompatibleKey(key) && this.ContainsKey((TKey)key));
 }