Class CustomCollection<T>
- Namespace
- NMF.Collections.ObjectModel
- Assembly
- NMF.Collections.dll
Denotes the base class for a custom collection
public abstract class CustomCollection<T> : ICollectionExpression<T>, IEnumerableExpression<T>, IEnumerableExpression, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
The element type
- Inheritance
-
CustomCollection<T>
- Implements
-
ICollection<T>IEnumerable<T>
- Inherited Members
- Extension Methods
Remarks
The idea behind this class is that developers turn an IEnumerableExpression into a ICollectionExpression by implementing Add, Remove and Clear
Constructors
CustomCollection(IEnumerableExpression<T>)
Creates a new instance
protected CustomCollection(IEnumerableExpression<T> inner)
Parameters
inner
IEnumerableExpression<T>The inner collection
Exceptions
- ArgumentNullException
Thrown if the inner collection is null
Properties
Count
Gets the number of elements contained in the ICollection<T>.
public int Count { get; }
Property Value
- int
The number of elements contained in the ICollection<T>.
Inner
Gets the inner collection
public IEnumerableExpression<T> Inner { get; }
Property Value
IsReadOnly
Gets a value indicating whether the ICollection<T> is read-only.
public bool IsReadOnly { get; }
Property Value
- bool
true if the ICollection<T> is read-only; otherwise, false.
Methods
Add(T)
Adds an item to the ICollection<T>.
public abstract void Add(T item)
Parameters
item
TThe object to add to the ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
AsNotifiable()
Gets notifications for this collection
public INotifyCollection<T> AsNotifiable()
Returns
- INotifyCollection<T>
A collection that will notify clients as new elements change
Clear()
Removes all items from the ICollection<T>.
public abstract void Clear()
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Contains(T)
Determines whether the ICollection<T> contains a specific value.
public virtual bool Contains(T item)
Parameters
item
TThe object to locate in the ICollection<T>.
Returns
- bool
true if
item
is found in the ICollection<T>; otherwise, false.
CopyTo(T[], int)
Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.
public void CopyTo(T[] array, int arrayIndex)
Parameters
array
T[]The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.
arrayIndex
intThe zero-based index in
array
at which copying begins.
Exceptions
- ArgumentNullException
array
is null.- ArgumentOutOfRangeException
arrayIndex
is less than 0.- ArgumentException
The number of elements in the source ICollection<T> is greater than the available space from
arrayIndex
to the end of the destinationarray
.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator that can be used to iterate through the collection.
Remove(T)
Removes the first occurrence of a specific object from the ICollection<T>.
public abstract bool Remove(T item)
Parameters
item
TThe object to remove from the ICollection<T>.
Returns
- bool
true if
item
was successfully removed from the ICollection<T>; otherwise, false. This method also returns false ifitem
is not found in the original ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.