From 367be8717cae540f5d3bdcdc0b416863eff7874a Mon Sep 17 00:00:00 2001 From: zerodev1200 <42404360+zerodev1200@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:20:29 +0900 Subject: [PATCH] add overload WritableFiltable ToWritableNotifyCollectionChanged() --- src/ObservableCollections/IObservableCollection.cs | 1 + src/ObservableCollections/ObservableList.Views.cs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ObservableCollections/IObservableCollection.cs b/src/ObservableCollections/IObservableCollection.cs index 2c8691b..9394f88 100644 --- a/src/ObservableCollections/IObservableCollection.cs +++ b/src/ObservableCollections/IObservableCollection.cs @@ -58,6 +58,7 @@ namespace ObservableCollections void SetToSourceCollection(int index, T value); void AddToSourceCollection(T value); IWritableSynchronizedViewList ToWritableViewList(WritableViewChangedEventHandler converter); + NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(); NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(WritableViewChangedEventHandler converter); NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(ICollectionEventDispatcher? collectionEventDispatcher); NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(WritableViewChangedEventHandler converter, ICollectionEventDispatcher? collectionEventDispatcher); diff --git a/src/ObservableCollections/ObservableList.Views.cs b/src/ObservableCollections/ObservableList.Views.cs index 7581db2..08fa810 100644 --- a/src/ObservableCollections/ObservableList.Views.cs +++ b/src/ObservableCollections/ObservableList.Views.cs @@ -373,6 +373,17 @@ namespace ObservableCollections return new FiltableSynchronizedViewList(this, isSupportRangeFeature: true, converter: converter); } + public NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged() + { + return new FiltableSynchronizedViewList(this, + isSupportRangeFeature: false, + converter: static (TView newView, T originalValue, ref bool setValue) => + { + setValue = true; + return originalValue; + }); + } + public NotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(WritableViewChangedEventHandler converter) { return new FiltableSynchronizedViewList(this, isSupportRangeFeature: false, converter: converter);