refactor: add removeAll method to observable collection

This commit is contained in:
k0t9i
2023-01-30 19:13:37 +04:00
parent 905b189bf2
commit 35e3f5e487
2 changed files with 31 additions and 22 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Application.Extensions
{
public static class ObservableCollectionExtensions
{
public static void RemoveAll<T>(this ObservableCollection<T> collection,
Func<T, bool> condition)
{
for (int i = collection.Count - 1; i >= 0; i--)
{
if (condition(collection[i]))
{
collection.RemoveAt(i);
}
}
}
}
}