diff --git a/src/ObservableCollections/IObservableCollection.cs b/src/ObservableCollections/IObservableCollection.cs index 0568de1..629627e 100644 --- a/src/ObservableCollections/IObservableCollection.cs +++ b/src/ObservableCollections/IObservableCollection.cs @@ -50,4 +50,34 @@ namespace ObservableCollections public interface INotifyCollectionChangedSynchronizedView : IReadOnlyCollection, INotifyCollectionChanged, INotifyPropertyChanged, IDisposable { } + + public static class ObservableCollectionExtensions + { + public static ISynchronizedViewList ToViewList(this IObservableCollection collection) + { + return ToViewList(collection, static x => x); + } + + public static ISynchronizedViewList ToViewList(this IObservableCollection collection, Func transform) + { + // Optimized for non filtered + return new NonFilteredSynchronizedViewList(collection.CreateView(transform)); + } + + public static INotifyCollectionChangedSynchronizedView ToNotifyCollectionChanged(this IObservableCollection collection) + { + return ToNotifyCollectionChanged(collection, null); + } + + public static INotifyCollectionChangedSynchronizedView ToNotifyCollectionChanged(this IObservableCollection collection, ICollectionEventDispatcher? collectionEventDispatcher) + { + return ToNotifyCollectionChanged(collection, static x => x, collectionEventDispatcher); + } + + public static INotifyCollectionChangedSynchronizedView ToNotifyCollectionChanged(this IObservableCollection collection, Func transform, ICollectionEventDispatcher? collectionEventDispatcher) + { + // Optimized for non filtered + return new NonFilteredNotifyCollectionChangedSynchronizedView(collection.CreateView(transform), collectionEventDispatcher); + } + } } \ No newline at end of file diff --git a/src/ObservableCollections/ObservableList.Views.cs b/src/ObservableCollections/ObservableList.Views.cs index d366b54..c965ee3 100644 --- a/src/ObservableCollections/ObservableList.Views.cs +++ b/src/ObservableCollections/ObservableList.Views.cs @@ -14,34 +14,6 @@ namespace ObservableCollections return new View(this, transform); } - public ISynchronizedViewList ToViewList() - { - // NOTE: for more optimize, no need to create View. - return ToViewList(static x => x); - } - - public ISynchronizedViewList ToViewList(Func transform) - { - // Optimized for non filtered - return new NonFilteredSynchronizedViewList(CreateView(transform)); - } - - public INotifyCollectionChangedSynchronizedView ToNotifyCollectionChanged() - { - return ToNotifyCollectionChanged(null); - } - - public INotifyCollectionChangedSynchronizedView ToNotifyCollectionChanged(ICollectionEventDispatcher? collectionEventDispatcher) - { - return ToNotifyCollectionChanged(static x => x, collectionEventDispatcher); - } - - public INotifyCollectionChangedSynchronizedView ToNotifyCollectionChanged(Func transform, ICollectionEventDispatcher? collectionEventDispatcher) - { - // Optimized for non filtered - return new NonFilteredNotifyCollectionChangedSynchronizedView(CreateView(transform), collectionEventDispatcher); - } - internal sealed class View : ISynchronizedView { public ISynchronizedViewFilter Filter