Add ObservableDictionary

This commit is contained in:
Mira 2022-10-14 13:18:36 +02:00
parent f63fdfca2f
commit 6031bb3f00
Signed by untrusted user who does not match committer: Xorog
GPG key ID: 983798ED9C3E7C36
4 changed files with 144 additions and 7 deletions

View file

@ -22,7 +22,7 @@ public class ObservableList<T> : IList<T>
{
this.ItemsChanged.Invoke(null, new ObservableListUpdate<T>
{
List = this,
List = this.ToList(),
NewItems = new List<T>() { item },
RemovedItems = null
});
@ -37,7 +37,7 @@ public class ObservableList<T> : IList<T>
{
this.ItemsChanged?.Invoke(null, new ObservableListUpdate<T>
{
List = this,
List = this.ToList(),
NewItems = new List<T>() { item },
RemovedItems = null
});
@ -46,15 +46,16 @@ public class ObservableList<T> : IList<T>
public void Clear()
{
var oldList = _items.ToList();
_items.Clear();
_ = Task.Run(() =>
{
this.ItemsChanged?.Invoke(null, new ObservableListUpdate<T>
{
List = this,
List = this.ToList(),
NewItems = null,
RemovedItems = _items.ToList()
RemovedItems = oldList
});
});
}
@ -63,7 +64,7 @@ public class ObservableList<T> : IList<T>
{
ObservableListUpdate<T> e = new ObservableListUpdate<T>
{
List = this,
List = this.ToList(),
NewItems = null,
RemovedItems = new List<T>() { _items.ElementAt(index) }
};
@ -84,7 +85,7 @@ public class ObservableList<T> : IList<T>
{
this.ItemsChanged?.Invoke(null, new ObservableListUpdate<T>
{
List = this,
List = this.ToList(),
NewItems = null,
RemovedItems = new List<T>() { item }
});