Created
February 8, 2022 17:08
-
-
Save RolandPheasant/5ffa1ce6dc8adebe0c4bd00222db1074 to your computer and use it in GitHub Desktop.
How to implement ICollection and ISourceList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MySourceList<T>: ISourceList<T>, ICollection<T> | |
{ | |
private readonly ISourceList<T> _innerList; | |
public MySourceList() | |
{ | |
_innerList = new SourceList<T>(); | |
} | |
public int Count => _innerList.Count; | |
public IObservable<int> CountChanged => _innerList.CountChanged; | |
public IEnumerable<T> Items => _innerList.Items; | |
public IObservable<IChangeSet<T>> Connect(Func<T, bool>? predicate = null) => _innerList.Connect(predicate); | |
public IObservable<IChangeSet<T>> Preview(Func<T, bool>? predicate = null) => _innerList.Preview(predicate); | |
public void Edit(Action<IExtendedList<T>> updateAction) => _innerList.Edit(updateAction); | |
public void Dispose() => _innerList.Dispose(); | |
public void Add(T item) => _innerList.Add(item); | |
public void Clear() => _innerList.Clear(); | |
public bool Contains(T item) => throw new NotImplementedException(); | |
public void CopyTo(T[] array, int arrayIndex) => throw new NotImplementedException(); | |
public bool Remove(T item) => _innerList.Remove(item); | |
public bool IsReadOnly => false; | |
public IEnumerator<T> GetEnumerator() => _innerList.Items.GetEnumerator(); | |
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment