Beispiel #1
0
        void System.Collections.IDictionary.Add(Object key, Object value)
        {
            if (key == null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
            }

            ThrowHelper.IfNullAndNullsAreIllegalThenThrow <TValue>(value, ExceptionArgument.value);

            try {
                TKey tempKey = (TKey)key;

                try {
                    Add(tempKey, (TValue)value);
                }
                catch (InvalidCastException) {
                    ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(TValue));
                }
            }
            catch (InvalidCastException) {
                ThrowHelper.ThrowWrongKeyTypeArgumentException(key, typeof(TKey));
            }
        }
 void IDictionary.Add(object key, object value)
 {
     if (key == null)
     {
         ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
     }
     ThrowHelper.IfNullAndNullsAreIllegalThenThrow <TValue>(value, ExceptionArgument.value);
     try
     {
         TKey local = (TKey)key;
         try
         {
             this.Add(local, (TValue)value);
         }
         catch (InvalidCastException)
         {
             ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(TValue));
         }
     }
     catch (InvalidCastException)
     {
         ThrowHelper.ThrowWrongKeyTypeArgumentException(key, typeof(TKey));
     }
 }