Files
Daybreak/Daybreak.Shared/Models/BatchedObservableCollection.cs
T
amacocian 721ee8e494 Huge application refactoring to better support plugins (#960)
* Move shared code to Shared project
* Move from Realm to Squealify
* Rename Daybreak.Shared namespaces
* Setup API project to expose a test API
2025-05-14 16:15:27 +02:00

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));
}
}