using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
namespace QuiverLauncher.Services;
///
/// ObservableCollection that can replace its contents with a single Reset notification.
///
public sealed class ResettableObservableCollection : ObservableCollection
{
public void ReplaceWith(IEnumerable items)
{
ArgumentNullException.ThrowIfNull(items);
CheckReentrancy();
Items.Clear();
foreach (var item in items)
Items.Add(item);
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Count)));
OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}