Class BulkObservableCollection<T>
- Namespace
- McServerLauncher.ViewModels
- Assembly
- McServerLauncher.dll
ObservableCollection with bulk operations that raise a single Reset event instead of one CollectionChanged per element. Used by the console lists (EFI-4): a verbose server (e.g. Forge booting) used to pay one RemoveAt(0) — an O(n) array shift plus a UI notification — for every line beyond the cap; trimming in blocks makes that a single cheap Reset every couple hundred lines, which the virtualized ListBox absorbs by re-rendering only the visible viewport.
public sealed class BulkObservableCollection<T> : ObservableCollection<T>, IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Type Parameters
T
- Inheritance
-
Collection<T>BulkObservableCollection<T>
- Implements
-
IList<T>ICollection<T>IEnumerable<T>
- Inherited Members
Methods
AddRange(IReadOnlyList<T>)
Appends items, raising one Add for all of them.
public void AddRange(IReadOnlyList<T> items)
Parameters
itemsIReadOnlyList<T>
Remarks
An Add, not a Reset, for the same reason as RemoveFromStart(int): the list keeps the containers it has and only builds the new ones. Used by the console, which takes the lines a server printed in one go instead of one notification per line.
RemoveFromStart(int)
Removes the first count items, raising one notification.
public void RemoveFromStart(int count)
Parameters
countint
Remarks
The notification says what actually happened — these items, from the front — rather than "everything changed". A Reset tells a virtualized list nothing about what it still has, so it throws away every container it had realized and builds them all again; saying which items left lets it keep the ones the user is looking at. On the console that is the difference between a visible hitch every couple of hundred lines and nothing at all.
ReplaceAll(IEnumerable<T>)
Replaces the whole content with items, raising one Reset.
public void ReplaceAll(IEnumerable<T> items)
Parameters
itemsIEnumerable<T>