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>
- 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.
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
- bool:
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
- bool:
true
if this instance is sorting its items; otherwise,false
.
this[int]
Gets or sets the element at the specified index.
public T this[int index] { get; set; }
Parameter | Type | Description |
---|---|---|
index | int | 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(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
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
- bool:
true
if item is found in the collection; otherwise,false
.
CopyTo(T[], int)
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 | int | 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(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
- int:
The index of
value
if found in the list; otherwise,-1
.
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
- int:
The index of item if found in the list; otherwise,
-1
.
Insert(int, object)
Inserts an item to the list at the specified index.
public void Insert(int index, object value)
Parameter | Type | Description |
---|---|---|
index | int | The zero-based index at which |
value | object | The object to insert into the list. |
Insert(int, T)
Inserts an item to the list at the specified index.
public void Insert(int index, T item)
Parameter | Type | Description |
---|---|---|
index | int | The zero-based index at which item should be inserted. |
item | T | 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(int)
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 | int | 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
- bool:
true
if item was successfully removed from the collection; otherwise,false
. This method also returnsfalse
if item is not found in the original collection.
RemoveAt(int)
Removes the list item at the specified index.
public void RemoveAt(int index)
Parameter | Type | Description |
---|---|---|
index | int | The zero-based index of the item to remove. |
Events
CollectionChanged
Occurs when the collection changes.
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()