mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-07-25 08:22:07 +00:00
* Move shared code to Shared project * Move from Realm to Squealify * Rename Daybreak.Shared namespaces * Setup API project to expose a test API
44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.Specialized;
|
|
|
|
namespace Daybreak.Shared.Models;
|
|
|
|
public class BatchedObservableCollection<T> : ObservableCollection<T>
|
|
{
|
|
public void RemoveBatch(IEnumerable<T> values)
|
|
{
|
|
this.CheckReentrancy();
|
|
var changed = false;
|
|
foreach (var value in values)
|
|
{
|
|
this.Items.Remove(value);
|
|
changed = true;
|
|
}
|
|
|
|
if (!changed)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
|
}
|
|
|
|
public void AddBatch(IEnumerable<T> values)
|
|
{
|
|
this.CheckReentrancy();
|
|
var changed = false;
|
|
foreach (var value in values)
|
|
{
|
|
this.Items.Add(value);
|
|
}
|
|
|
|
if (!changed)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
|
}
|
|
}
|