Adjust Clash API (#10088)

This commit is contained in:
DHR60
2026-09-03 12:21:46 +00:00
committed by GitHub
parent f03db020fa
commit 093b8d4c34
25 changed files with 440 additions and 515 deletions
@@ -2,7 +2,14 @@ namespace ServiceLib.Base;
public class BulkObservableCollection<T> : ObservableCollection<T>
{
private bool _suppressNotification = false;
private bool _suppressNotification;
public BulkObservableCollection()
{
}
public BulkObservableCollection(IEnumerable<T> collection) : base(collection) { }
public BulkObservableCollection(List<T> list) : base(list) { }
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
@@ -63,4 +70,29 @@ public class BulkObservableCollection<T> : ObservableCollection<T>
return true;
}
public void ReplaceRange(IEnumerable<T>? collection)
{
if (collection == null)
{
return;
}
_suppressNotification = true;
try
{
Items.Clear();
foreach (var item in collection)
{
Items.Add(item);
}
}
finally
{
_suppressNotification = false;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Count)));
OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
}