Some refactoring

This commit is contained in:
TheXamlGuy
2024-06-09 22:41:58 +01:00
parent 8d20c0a8c0
commit 5a98b67dcf
34 changed files with 177 additions and 106 deletions
+12 -5
View File
@@ -155,6 +155,12 @@ public partial class ObservableCollection<TItem> :
return item;
}
public void Clear(Action<ObservableCollection<TItem>> factory)
{
Clear();
factory.Invoke(this);
}
public void Add(TItem item)
{
int index = collection.Count;
@@ -274,7 +280,7 @@ public partial class ObservableCollection<TItem> :
{
foreach (TItem item in this.ToList())
{
if (args.Value is not null && args.Value.Equals(item))
if (args.Sender is not null && args.Sender.Equals(item))
{
Remove(item);
}
@@ -292,7 +298,7 @@ public partial class ObservableCollection<TItem> :
{
if (Activated)
{
if (args.Value is TItem item)
if (args.Sender is TItem item)
{
Add(item);
}
@@ -340,7 +346,7 @@ public partial class ObservableCollection<TItem> :
{
if (Activated)
{
if (args.Value is TItem item)
if (args.Sender is TItem item)
{
Move(args.Index, item);
}
@@ -357,7 +363,7 @@ public partial class ObservableCollection<TItem> :
{
if (Activated)
{
if (args.Value is TItem item)
if (args.Sender is TItem item)
{
Replace(args.Index, item);
}
@@ -715,7 +721,8 @@ public partial class ObservableCollection<TViewModel, TKey, TValue> :
partial void OnValueChanged(TValue value) => OnValueChanged();
}
public class ObservableCollection : ObservableCollection<IDisposable>
public class ObservableCollection :
ObservableCollection<IDisposable>
{
public ObservableCollection(IServiceProvider provider,
IServiceFactory factory,