Files
Daybreak/Daybreak.Shared/Models/BatchedObservableCollection.cs
amacocian ab1b604aec Code cleanup (#1026)
* Resolve warnings and move shared props to Directory.Build.props and Directory.Packages.props

* Cleanup more messages

* Fix more messages

* Fix build issues
2025-06-29 17:32:52 +02:00

43 lines
999 B
C#

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