Esempio n. 1
0
        int IList.Add(object value)
        {
            CollectionWrapper <T> .VerifyValueType(value);

            this.Add((T)value);
            return(this.Count - 1);
        }
Esempio n. 2
0
 void IList.Remove(object value)
 {
     if (!CollectionWrapper <T> .IsCompatibleObject(value))
     {
         return;
     }
     this.Remove((T)value);
 }
Esempio n. 3
0
 bool IList.Contains(object value)
 {
     if (CollectionWrapper <T> .IsCompatibleObject(value))
     {
         return(this.Contains((T)value));
     }
     return(false);
 }
Esempio n. 4
0
 private static void VerifyValueType(object value)
 {
     if (!CollectionWrapper <T> .IsCompatibleObject(value))
     {
         throw new ArgumentException(
                   "The value '{0}' is not of type '{1}' and cannot be used in this generic collection.".FormatWith(
                       (IFormatProvider)CultureInfo.InvariantCulture, value, (object)typeof(T)), nameof(value));
     }
 }
Esempio n. 5
0
        void IList.Insert(int index, object value)
        {
            if (this._genericCollection != null)
            {
                throw new InvalidOperationException("Wrapped ICollection<T> does not support Insert.");
            }
            CollectionWrapper <T> .VerifyValueType(value);

            this._list.Insert(index, (object)(T)value);
        }
Esempio n. 6
0
 int IList.IndexOf(object value)
 {
     if (this._genericCollection != null)
     {
         throw new InvalidOperationException("Wrapped ICollection<T> does not support IndexOf.");
     }
     if (CollectionWrapper <T> .IsCompatibleObject(value))
     {
         return(this._list.IndexOf((object)(T)value));
     }
     return(-1);
 }
Esempio n. 7
0
        object IList.this[int index] {
            get {
                if (this._genericCollection != null)
                {
                    throw new InvalidOperationException("Wrapped ICollection<T> does not support indexer.");
                }
                return(this._list[index]);
            }
            set {
                if (this._genericCollection != null)
                {
                    throw new InvalidOperationException("Wrapped ICollection<T> does not support indexer.");
                }
                CollectionWrapper <T> .VerifyValueType(value);

                this._list[index] = (object)(T)value;
            }
        }