In This Article

EnumerableView<T> Class

Represents a read-only view on top of an IEnumerable<T> with support for filtering, sorting, and change notifications.

public class EnumerableView<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, INotifyCollectionChanged
Type Parameters:
T -

The type of items.

Inheritance:
Object Object

Constructors

EnumerableView(IEnumerable<T>)

Initializes a new instance of the EnumerableView<T> class.

public EnumerableView(IEnumerable<T> collection)
Parameter Type Description
collection IEnumerable<T>

The collection to wrap/filter.

EnumerableView(IEnumerable<T>, IComparer<T>)

Initializes a new instance of the EnumerableView<T> class.

public EnumerableView(IEnumerable<T> collection, IComparer<T> sort)
Parameter Type Description
collection IEnumerable<T>

The collection to wrap/filter.

sort IComparer<T>

The sort logic.

EnumerableView(IEnumerable<T>, Comparison<T>)

Initializes a new instance of the EnumerableView<T> class.

public EnumerableView(IEnumerable<T> collection, Comparison<T> sort)
Parameter Type Description
collection IEnumerable<T>

The collection to wrap/filter.

sort Comparison<T>

The sort logic.

EnumerableView(IEnumerable<T>, Predicate<T>)

Initializes a new instance of the EnumerableView<T> class.

public EnumerableView(IEnumerable<T> collection, Predicate<T> filter)
Parameter Type Description
collection IEnumerable<T>

The collection to wrap/filter.

filter Predicate<T>

The filter logic.

EnumerableView(IEnumerable<T>, Predicate<T>, IComparer<T>)

Initializes a new instance of the EnumerableView<T> class.

public EnumerableView(IEnumerable<T> collection, Predicate<T> filter, IComparer<T> sort)
Parameter Type Description
collection IEnumerable<T>

The collection to wrap/filter.

filter Predicate<T>

The filter logic.

sort IComparer<T>

The sort logic.

EnumerableView(IEnumerable<T>, Predicate<T>, Comparison<T>)

Initializes a new instance of the EnumerableView<T> class.

public EnumerableView(IEnumerable<T> collection, Predicate<T> filter, Comparison<T> sort)
Parameter Type Description
collection IEnumerable<T>

The collection to wrap/filter.

filter Predicate<T>

The filter logic.

sort Comparison<T>

The sort logic.

Properties

Count

Gets the number of elements contained in the collection.

public int Count { get; }

Property Value

Int32:

The number of elements contained in the collection.

FilterPredicate

Gets or sets a filter predicate delegate, which can be used to filter the associated collection.

public Predicate<T> FilterPredicate { get; set; }

Property Value

Predicate<T>:

The filter logic, which returns true to filter an item.

IsReadOnly

Gets a value indicating whether the collection is read-only.

public bool IsReadOnly { get; }

Property Value

Boolean:

true if the collection is read-only; otherwise, false.

IsSorting

Gets a value indicating whether this instance is sorting its items.

public bool IsSorting { get; }

Property Value

Boolean:

true if this instance is sorting its items; otherwise, false.

Item[Int32]

Gets or sets the element at the specified index.

public T this[int index] { get; set; }
Parameter Type Description
index Int32

The zero-based index of the element to get or set.

Property Value

T:

The element at the specified index.

SortComparer

Gets or sets a sort comparer, which can be used to sort the associated collection.

public IComparer<T> SortComparer { get; set; }

Property Value

IComparer<T>:

The sort comparer, used to compare items for sorting.

Remarks

This property takes precedence over the SortComparison property.

SortComparison

Gets or sets a sort comparison delegate, which can be used to sort the associated collection.

public Comparison<T> SortComparison { get; set; }

Property Value

Comparison<T>:

The sort logic.

Remarks

The SortComparer property takes precedence over this property.

Methods

Add(T)

Adds an item to the collection.

public void Add(T item)
Parameter Type Description
item T

The object to add to the collection.

Clear()

Removes all items from the collection.

public void Clear()

Contains(T)

Determines whether the collection contains a specific value.

public bool Contains(T item)
Parameter Type Description
item T

The object to locate in the collection.

Returns

Boolean:

true if item is found in the collection; otherwise, false.

Contains(Object)

Determines whether the list contains a specific value.

public bool Contains(object value)
Parameter Type Description
value Object

The Object to locate in the list.

Returns

Boolean:

true if the Object is found in the list; otherwise, false.

CopyTo(T[], Int32)

Copies the elements of the collection to an Array, starting at a particular Array index.

public void CopyTo(T[] array, int arrayIndex)
Parameter Type Description
array T[]

The one-dimensional Array that is the destination of the elements copied from collection. The Array must have zero-based indexing..

arrayIndex Int32

The zero-based index in array at which copying begins.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>:

A IEnumerator<T> that can be used to iterate through the collection.

IndexOf(T)

Determines the index of a specific item in the list.

public int IndexOf(T item)
Parameter Type Description
item T

The object to locate in the list.

Returns

Int32:

The index of item if found in the list; otherwise, -1.

IndexOf(Object)

Determines the index of a specific item in the list.

public int IndexOf(object value)
Parameter Type Description
value Object

The Object to locate in the list.

Returns

Int32:

The index of value if found in the list; otherwise, -1.

Insert(Int32, T)

Inserts an item to the list at the specified index.

public void Insert(int index, T item)
Parameter Type Description
index Int32

The zero-based index at which item should be inserted.

item T

The object to insert into the list.

Insert(Int32, Object)

Inserts an item to the list at the specified index.

public void Insert(int index, object value)
Parameter Type Description
index Int32

The zero-based index at which value should be inserted.

value Object

The Object to insert into the list.

Reevaluate(T)

Reevaluates the filtering and sorting logic applied to the specified item from the associated collection.

public void Reevaluate(T item)
Parameter Type Description
item T

The item to reevaluate.

ReevaluateAt(Int32)

Reevaluates the filtering and sorting logic applied to the item at the specified index relative to the associated collection.

public void ReevaluateAt(int index)
Parameter Type Description
index Int32

The index of the item to reevaluate.

Remove(T)

Removes the first occurrence of a specific object from the collection.

public bool Remove(T item)
Parameter Type Description
item T

The object to remove from the collection.

Returns

Boolean:

true if item was successfully removed from the collection; otherwise, false. This method also returns false if item is not found in the original collection.

RemoveAt(Int32)

Removes the list item at the specified index.

public void RemoveAt(int index)
Parameter Type Description
index Int32

The zero-based index of the item to remove.

Events

CollectionChanged

Occurs when the collection changes.

public event NotifyCollectionChangedEventHandler CollectionChanged

Event Type

NotifyCollectionChangedEventHandler

Inherited Members