Class ObservableRangeCollection<T>
Implementation of a dynamic data collection based on generic Collection<T>, implementing INotifyCollectionChanged to notify listeners when items get added, removed or the whole list is refreshed.
Inherited Members
Namespace: Mapsui.Utilities
Assembly: Mapsui.dll
Syntax
public class ObservableRangeCollection<T> : ObservableCollection<T>, IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Type Parameters
Name | Description |
---|---|
T | Implementation of a dynamic data collection based on generic Collection<T>, implementing INotifyCollectionChanged to notify listeners when items get added, removed or the whole list is refreshed. |
Constructors
| Edit this page View SourceObservableRangeCollection()
Initializes a new instance of ObservableCollection that is empty and has default initial capacity.
Declaration
public ObservableRangeCollection()
ObservableRangeCollection(IEnumerable<T>)
Initializes a new instance of the ObservableCollection class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.
Declaration
public ObservableRangeCollection(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The collection whose elements are copied to the new list. |
Remarks
The elements are copied onto the ObservableCollection in the same order they are read by the enumerator of the collection.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | collection is a null reference |
ObservableRangeCollection(List<T>)
Initializes a new instance of the ObservableCollection class that contains elements copied from the specified list
Declaration
public ObservableRangeCollection(List<T> list)
Parameters
Type | Name | Description |
---|---|---|
List<T> | list | The list whose elements are copied to the new list. |
Remarks
The elements are copied onto the ObservableCollection in the same order they are read by the enumerator of the list.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | list is a null reference |
Methods
| Edit this page View SourceAddRange(IEnumerable<T>)
Adds the elements of the specified collection to the end of the ObservableCollection<T>.
Declaration
public void AddRange(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The collection whose elements should be added to the end of the ObservableCollection<T>. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ClearItems()
Called by base class Collection<T> when the list is being cleared; raises a CollectionChanged event to any listeners.
Declaration
protected override void ClearItems()
Overrides
| Edit this page View SourceDeferEvents()
Declaration
protected virtual IDisposable DeferEvents()
Returns
Type | Description |
---|---|
IDisposable |
InsertRange(int, IEnumerable<T>)
Inserts the elements of a collection into the ObservableCollection<T> at the specified index.
Declaration
public void InsertRange(int index, IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index at which the new elements should be inserted. |
IEnumerable<T> | collection | The collection whose elements should be inserted into the List{T}. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Raise CollectionChanged event to any listeners. Properties/methods modifying this ObservableCollection will raise a collection changed event through this virtual method.
Declaration
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
NotifyCollectionChangedEventArgs | e |
Overrides
Remarks
When overriding this method, either call its base implementation or call BlockReentrancy() to guard against reentrant collection changes.
RemoveAll(int, int, Predicate<T>)
Iterates over the specified range within the collection and removes all items that satisfy the specified match.
Declaration
public int RemoveAll(int index, int count, Predicate<T> match)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of where to start performing the search. |
int | count | The number of items to iterate on. |
Predicate<T> | match |
Returns
Type | Description |
---|---|
int | Returns the number of elements that where |
Remarks
The complexity is O(n).
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ArgumentOutOfRangeException |
|
ArgumentNullException |
|
RemoveAll(Predicate<T>)
Iterates over the collection and removes all items that satisfy the specified match.
Declaration
public int RemoveAll(Predicate<T> match)
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | match |
Returns
Type | Description |
---|---|
int | Returns the number of elements that where |
Remarks
The complexity is O(n).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
RemoveRange(IEnumerable<T>)
Removes the first occurence of each item in the specified collection from the ObservableCollection<T>.
Declaration
public void RemoveRange(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The items to remove. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
RemoveRange(int, int)
Removes a range of elements from the ObservableCollection<T>>.
Declaration
public void RemoveRange(int index, int count)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based starting index of the range of elements to remove. |
int | count | The number of elements to remove. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The specified range is exceeding the collection. |
ReplaceRange(IEnumerable<T>)
Clears the current collection and replaces it with the specified collection, using the default EqualityComparer<T>.
Declaration
public void ReplaceRange(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The items to fill the collection with, after clearing it. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ReplaceRange(IEnumerable<T>, IEqualityComparer<T>)
Clears the current collection and replaces it with the specified collection, using the specified comparer to skip equal items.
Declaration
public void ReplaceRange(IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The items to fill the collection with, after clearing it. |
IEqualityComparer<T> | comparer | An IEqualityComparer<T> to be used to check whether an item in the same location already existed before, which in case it would not be added to the collection, and no event will be raised for it. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ReplaceRange(int, int, IEnumerable<T>)
Removes the specified range and inserts the specified collection, ignoring equal items (using Default).
Declaration
public void ReplaceRange(int index, int count, IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of where to start the replacement. |
int | count | The number of items to be replaced. |
IEnumerable<T> | collection | The collection to insert in that location. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ArgumentOutOfRangeException |
|
ArgumentNullException |
|
ReplaceRange(int, int, IEnumerable<T>, IEqualityComparer<T>)
Removes the specified range and inserts the specified collection in its position, leaving equal items in equal positions intact.
Declaration
public void ReplaceRange(int index, int count, IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of where to start the replacement. |
int | count | The number of items to be replaced. |
IEnumerable<T> | collection | The collection to insert in that location. |
IEqualityComparer<T> | comparer | The comparer to use when checking for equal items. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ArgumentOutOfRangeException |
|
ArgumentNullException |
|
ArgumentNullException |
|
SetItem(int, T)
Called by base class Collection<T> when an item is set in list; raises a CollectionChanged event to any listeners.
Declaration
protected override void SetItem(int index, T item)
Parameters
Type | Name | Description |
---|---|---|
int | index | |
T | item |