Пример #1
0
 /// <summary>
 /// Adds an item to this collection.
 /// </summary>
 /// <param name="value">
 /// The item to be added.
 /// </param>
 /// <returns>
 /// The index of the added item.
 /// </returns>
 int System.Collections.IList.Add(object value)
 {
     ArgumentHelper.AssertNotNull(value, "value");
     ExceptionHelper.ThrowIf(!(value is TItem), "WrongType", value.GetType().FullName, typeof(TItem).FullName);
     Add((TItem)value);
     return(Count - 1);
 }
Пример #2
0
        /// <summary>
        /// Determines the index of <paramref name="value"/> within this collection.
        /// </summary>
        /// <param name="value">
        /// The item to search for.
        /// </param>
        /// <returns>
        /// The index of the item in this filtered collection, or <c>-1</c> if it could not be found.
        /// </returns>
        int System.Collections.IList.IndexOf(object value)
        {
            if (value != null)
            {
                ExceptionHelper.ThrowIf(!(value is TItem), "WrongType", value.GetType().FullName, typeof(TItem).FullName);
            }

            return(IndexOf((TItem)value));
        }
Пример #3
0
        /// <summary>
        /// Copies all items in this collection to the specified array.
        /// </summary>
        /// <param name="array">
        /// The array to copy to.
        /// </param>
        /// <param name="arrayIndex">
        /// The starting index for the copy operation.
        /// </param>
        void System.Collections.ICollection.CopyTo(Array array, int index)
        {
            ArgumentHelper.AssertNotNull(array, "array");
            ExceptionHelper.ThrowIf(index < 0, "CopyTo.ArrayIndexNegative");

            for (int i = 0; i < this.Count; ++i)
            {
                array.SetValue(this[i], i + index);
            }
        }
Пример #4
0
 /// <summary>
 /// Gets or sets an item in this filtered collection.
 /// </summary>
 /// <param name="index">
 /// The index of the item.
 /// </param>
 /// <returns>
 /// The item at the specified index.
 /// </returns>
 object System.Collections.IList.this[int index]
 {
     get
     {
         return(this[index]);
     }
     set
     {
         ArgumentHelper.AssertNotNull(value, "value");
         ExceptionHelper.ThrowIf(!(value is TItem), "WrongType", value.GetType().FullName, typeof(TItem).FullName);
         this[index] = (TItem)value;
     }
 }
Пример #5
0
 /// <summary>
 /// Removes the specified item from this filtered collection.
 /// </summary>
 /// <param name="value">
 /// The item to remove.
 /// </param>
 /// <returns>
 /// <see langword="true"/> if the item was removed, otherwise <see langword="false"/>.
 /// </returns>
 void System.Collections.IList.Remove(object value)
 {
     ArgumentHelper.AssertNotNull(value, "value");
     ExceptionHelper.ThrowIf(!(value is TItem), "WrongType", value.GetType().FullName, typeof(TItem).FullName);
     Remove((TItem)value);
 }