From 1b3a81ad8d87120ce540cca1667b46f8a35b045d Mon Sep 17 00:00:00 2001 From: zerodev1200 <42404360+zerodev1200@users.noreply.github.com> Date: Sun, 6 Oct 2024 22:29:05 +0900 Subject: [PATCH] add overload, and change the order of arguments --- .../IObservableCollection.cs | 1 + .../ObservableList.Views.cs | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/ObservableCollections/IObservableCollection.cs b/src/ObservableCollections/IObservableCollection.cs index 1372d12..226617a 100644 --- a/src/ObservableCollections/IObservableCollection.cs +++ b/src/ObservableCollections/IObservableCollection.cs @@ -58,6 +58,7 @@ namespace ObservableCollections void SetToSourceCollection(int index, T value); IWritableSynchronizedViewList ToWritableViewList(WritableViewChangedEventHandler converter); INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(WritableViewChangedEventHandler converter); + INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(ICollectionEventDispatcher? collectionEventDispatcher); INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(WritableViewChangedEventHandler converter, ICollectionEventDispatcher? collectionEventDispatcher); } diff --git a/src/ObservableCollections/ObservableList.Views.cs b/src/ObservableCollections/ObservableList.Views.cs index f37d86d..62dc634 100644 --- a/src/ObservableCollections/ObservableList.Views.cs +++ b/src/ObservableCollections/ObservableList.Views.cs @@ -26,19 +26,22 @@ namespace ObservableCollections public INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(ICollectionEventDispatcher? collectionEventDispatcher) { - return ToWritableNotifyCollectionChanged(static x => x, collectionEventDispatcher, static (T newView, T originalValue, ref bool setValue) => - { - setValue = true; - return newView; - }); + return ToWritableNotifyCollectionChanged( + static x => x, + static (T newView, T originalValue, ref bool setValue) => + { + setValue = true; + return newView; + }, + collectionEventDispatcher); } public INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(Func transform, WritableViewChangedEventHandler? converter) { - return ToWritableNotifyCollectionChanged(transform, null!); + return ToWritableNotifyCollectionChanged(transform, converter, null!); } - public INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(Func transform, ICollectionEventDispatcher? collectionEventDispatcher, WritableViewChangedEventHandler? converter) + public INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(Func transform, WritableViewChangedEventHandler? converter, ICollectionEventDispatcher? collectionEventDispatcher) { return new NonFilteredNotifyCollectionChangedSynchronizedViewList(CreateView(transform), collectionEventDispatcher, converter); } @@ -367,9 +370,19 @@ namespace ObservableCollections return new NotifyCollectionChangedSynchronizedViewList(this, null, converter); } + public INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(ICollectionEventDispatcher? collectionEventDispatcher) + { + return new NotifyCollectionChangedSynchronizedViewList(this, collectionEventDispatcher, + static (TView newView, T originalValue, ref bool setValue) => + { + setValue = true; + return originalValue; + }); + } + public INotifyCollectionChangedSynchronizedViewList ToWritableNotifyCollectionChanged(WritableViewChangedEventHandler converter, ICollectionEventDispatcher? collectionEventDispatcher) { - return new NotifyCollectionChangedSynchronizedViewList(this, null, converter); + return new NotifyCollectionChangedSynchronizedViewList(this, collectionEventDispatcher, converter); } #endregion