diff --git a/src/ObservableCollections/IObservableCollection.cs b/src/ObservableCollections/IObservableCollection.cs index 757c1d4..ed7aca3 100644 --- a/src/ObservableCollections/IObservableCollection.cs +++ b/src/ObservableCollections/IObservableCollection.cs @@ -83,7 +83,7 @@ public interface INotifyCollectionChangedSynchronizedViewList : IList.Count and ICollection.Count will be ambigious so use abstract class instead of interface + // ICollection.Count and ICollection.Count will be ambiguous so use abstract class instead of interface public abstract class NotifyCollectionChangedSynchronizedViewList : INotifyCollectionChangedSynchronizedViewList, IWritableSynchronizedViewList, @@ -232,5 +232,11 @@ public static NotifyCollectionChangedSynchronizedViewList ToNotifyCollect // Optimized for non filtered return new NonFilteredSynchronizedViewList(collection.CreateView(transform), isSupportRangeFeature: false, collectionEventDispatcher, null); } + + public static NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChanged(this IObservableCollection collection, Func transform, bool supportsRangeFeature, ICollectionEventDispatcher? collectionEventDispatcher) + { + // Optimized for non filtered + return new NonFilteredSynchronizedViewList(collection.CreateView(transform), supportsRangeFeature, collectionEventDispatcher, null); + } } } diff --git a/src/ObservableCollections/ObservableDictionary.Views.cs b/src/ObservableCollections/ObservableDictionary.Views.cs index 4c0d450..91c1fc1 100644 --- a/src/ObservableCollections/ObservableDictionary.Views.cs +++ b/src/ObservableCollections/ObservableDictionary.Views.cs @@ -124,6 +124,11 @@ public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChan return new FiltableSynchronizedViewList, TView>(this, isSupportRangeFeature: false, collectionEventDispatcher); } + public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChanged(bool supportsRangeFeature, ICollectionEventDispatcher? collectionEventDispatcher) + { + return new FiltableSynchronizedViewList, TView>(this, supportsRangeFeature, collectionEventDispatcher); + } + public IEnumerator GetEnumerator() { lock (SyncRoot) @@ -221,4 +226,4 @@ private void SourceCollectionChanged(in NotifyCollectionChangedEventArgs ToNotifyCollectionChan return new FiltableSynchronizedViewList(this, isSupportRangeFeature: false, collectionEventDispatcher); } + public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChanged(bool supportsRangeFeature, ICollectionEventDispatcher? collectionEventDispatcher) + { + return new FiltableSynchronizedViewList(this, supportsRangeFeature, collectionEventDispatcher); + } + public IEnumerator GetEnumerator() { lock (SyncRoot) diff --git a/src/ObservableCollections/ObservableList.Views.cs b/src/ObservableCollections/ObservableList.Views.cs index c63f074..be08596 100644 --- a/src/ObservableCollections/ObservableList.Views.cs +++ b/src/ObservableCollections/ObservableList.Views.cs @@ -46,6 +46,11 @@ public NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollec return new NonFilteredSynchronizedViewList(CreateView(transform), isSupportRangeFeature: false, collectionEventDispatcher, converter); } + public NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(Func transform, bool supportsRangeFeature, WritableViewChangedEventHandler? converter, ICollectionEventDispatcher? collectionEventDispatcher) + { + return new NonFilteredSynchronizedViewList(CreateView(transform), supportsRangeFeature, collectionEventDispatcher, converter); + } + internal sealed class View : ISynchronizedView, IWritableSynchronizedView { public ISynchronizedViewFilter Filter @@ -154,6 +159,11 @@ public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChan return new FiltableSynchronizedViewList(this, isSupportRangeFeature: false, collectionEventDispatcher); } + public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChanged(bool supportsRangeFeature, ICollectionEventDispatcher? collectionEventDispatcher) + { + return new FiltableSynchronizedViewList(this, supportsRangeFeature, collectionEventDispatcher); + } + public IEnumerator GetEnumerator() { lock (SyncRoot) @@ -432,11 +442,28 @@ public NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollec }); } + public NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(bool supportsRangeFeature, ICollectionEventDispatcher? collectionEventDispatcher) + { + return new FiltableSynchronizedViewList(this, + supportsRangeFeature, + eventDispatcher: collectionEventDispatcher, + converter: static (TView newView, T originalValue, ref bool setValue) => + { + setValue = true; + return originalValue; + }); + } + public NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(WritableViewChangedEventHandler converter, ICollectionEventDispatcher? collectionEventDispatcher) { return new FiltableSynchronizedViewList(this, isSupportRangeFeature: false, collectionEventDispatcher, converter); } + public NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(bool supportsRangeFeature, WritableViewChangedEventHandler converter, ICollectionEventDispatcher? collectionEventDispatcher) + { + return new FiltableSynchronizedViewList(this, supportsRangeFeature, collectionEventDispatcher, converter); + } + #endregion sealed class IgnoreViewComparer : IComparer<(T, TView)> diff --git a/src/ObservableCollections/ObservableQueue.Views.cs b/src/ObservableCollections/ObservableQueue.Views.cs index 55d0184..4adf400 100644 --- a/src/ObservableCollections/ObservableQueue.Views.cs +++ b/src/ObservableCollections/ObservableQueue.Views.cs @@ -119,6 +119,11 @@ public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChan return new FiltableSynchronizedViewList(this, isSupportRangeFeature: false, collectionEventDispatcher); } + public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChanged(bool supportsRangeFeature, ICollectionEventDispatcher? collectionEventDispatcher) + { + return new FiltableSynchronizedViewList(this, supportsRangeFeature, collectionEventDispatcher); + } + public IEnumerator GetEnumerator() { lock (SyncRoot) @@ -228,4 +233,4 @@ private void SourceCollectionChanged(in NotifyCollectionChangedEventArgs e) } } } -} \ No newline at end of file +} diff --git a/src/ObservableCollections/ObservableRingBuffer.Views.cs b/src/ObservableCollections/ObservableRingBuffer.Views.cs index 269c849..6bbdaf6 100644 --- a/src/ObservableCollections/ObservableRingBuffer.Views.cs +++ b/src/ObservableCollections/ObservableRingBuffer.Views.cs @@ -127,6 +127,14 @@ public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChan } } + public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChanged(bool supportsRangeFeature, ICollectionEventDispatcher? collectionEventDispatcher) + { + lock (SyncRoot) + { + return new FiltableSynchronizedViewList(this, supportsRangeFeature, collectionEventDispatcher); + } + } + public IEnumerator GetEnumerator() { lock (SyncRoot) @@ -291,4 +299,4 @@ private void SourceCollectionChanged(in NotifyCollectionChangedEventArgs e) } } } -} \ No newline at end of file +} diff --git a/src/ObservableCollections/ObservableStack.Views.cs b/src/ObservableCollections/ObservableStack.Views.cs index 9d6c370..25d8133 100644 --- a/src/ObservableCollections/ObservableStack.Views.cs +++ b/src/ObservableCollections/ObservableStack.Views.cs @@ -124,6 +124,14 @@ public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChan } } + public NotifyCollectionChangedSynchronizedViewList ToNotifyCollectionChanged(bool supportsRangeFeature, ICollectionEventDispatcher? collectionEventDispatcher) + { + lock (SyncRoot) + { + return new FiltableSynchronizedViewList(this, supportsRangeFeature, collectionEventDispatcher); + } + } + public IEnumerator GetEnumerator() { lock (SyncRoot) diff --git a/src/ObservableCollections/SynchronizedViewList.cs b/src/ObservableCollections/SynchronizedViewList.cs index 8b146a1..c45fbca 100644 --- a/src/ObservableCollections/SynchronizedViewList.cs +++ b/src/ObservableCollections/SynchronizedViewList.cs @@ -16,7 +16,7 @@ internal sealed class FiltableSynchronizedViewList : NotifyCollectionC readonly ISynchronizedView parent; readonly AlternateIndexList listView; - readonly bool isSupportRangeFeature; // WPF, Avalonia etc does not support range notification + readonly bool isSupportRangeFeature; // WPF, etc does not support range notification readonly ICollectionEventDispatcher eventDispatcher; readonly WritableViewChangedEventHandler? converter; // null = readonly @@ -522,7 +522,7 @@ internal sealed class NonFilteredSynchronizedViewList : NotifyCollecti readonly ISynchronizedView parent; readonly List listView; // no filter can be faster - readonly bool isSupportRangeFeature; // WPF, Avalonia etc does not support range notification + readonly bool isSupportRangeFeature; // WPF, etc does not support range notification readonly ICollectionEventDispatcher eventDispatcher; readonly WritableViewChangedEventHandler? converter; // null = readonly