to extension
This commit is contained in:
parent
67c41178dd
commit
bef0269e02
@ -50,4 +50,34 @@ namespace ObservableCollections
|
||||
public interface INotifyCollectionChangedSynchronizedView<out TView> : IReadOnlyCollection<TView>, INotifyCollectionChanged, INotifyPropertyChanged, IDisposable
|
||||
{
|
||||
}
|
||||
|
||||
public static class ObservableCollectionExtensions
|
||||
{
|
||||
public static ISynchronizedViewList<T> ToViewList<T>(this IObservableCollection<T> collection)
|
||||
{
|
||||
return ToViewList(collection, static x => x);
|
||||
}
|
||||
|
||||
public static ISynchronizedViewList<TView> ToViewList<T, TView>(this IObservableCollection<T> collection, Func<T, TView> transform)
|
||||
{
|
||||
// Optimized for non filtered
|
||||
return new NonFilteredSynchronizedViewList<T, TView>(collection.CreateView(transform));
|
||||
}
|
||||
|
||||
public static INotifyCollectionChangedSynchronizedView<T> ToNotifyCollectionChanged<T>(this IObservableCollection<T> collection)
|
||||
{
|
||||
return ToNotifyCollectionChanged(collection, null);
|
||||
}
|
||||
|
||||
public static INotifyCollectionChangedSynchronizedView<T> ToNotifyCollectionChanged<T>(this IObservableCollection<T> collection, ICollectionEventDispatcher? collectionEventDispatcher)
|
||||
{
|
||||
return ToNotifyCollectionChanged(collection, static x => x, collectionEventDispatcher);
|
||||
}
|
||||
|
||||
public static INotifyCollectionChangedSynchronizedView<TView> ToNotifyCollectionChanged<T, TView>(this IObservableCollection<T> collection, Func<T, TView> transform, ICollectionEventDispatcher? collectionEventDispatcher)
|
||||
{
|
||||
// Optimized for non filtered
|
||||
return new NonFilteredNotifyCollectionChangedSynchronizedView<T, TView>(collection.CreateView(transform), collectionEventDispatcher);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,34 +14,6 @@ namespace ObservableCollections
|
||||
return new View<TView>(this, transform);
|
||||
}
|
||||
|
||||
public ISynchronizedViewList<T> ToViewList()
|
||||
{
|
||||
// NOTE: for more optimize, no need to create View.
|
||||
return ToViewList(static x => x);
|
||||
}
|
||||
|
||||
public ISynchronizedViewList<TView> ToViewList<TView>(Func<T, TView> transform)
|
||||
{
|
||||
// Optimized for non filtered
|
||||
return new NonFilteredSynchronizedViewList<T, TView>(CreateView(transform));
|
||||
}
|
||||
|
||||
public INotifyCollectionChangedSynchronizedView<T> ToNotifyCollectionChanged()
|
||||
{
|
||||
return ToNotifyCollectionChanged(null);
|
||||
}
|
||||
|
||||
public INotifyCollectionChangedSynchronizedView<T> ToNotifyCollectionChanged(ICollectionEventDispatcher? collectionEventDispatcher)
|
||||
{
|
||||
return ToNotifyCollectionChanged(static x => x, collectionEventDispatcher);
|
||||
}
|
||||
|
||||
public INotifyCollectionChangedSynchronizedView<TView> ToNotifyCollectionChanged<TView>(Func<T, TView> transform, ICollectionEventDispatcher? collectionEventDispatcher)
|
||||
{
|
||||
// Optimized for non filtered
|
||||
return new NonFilteredNotifyCollectionChangedSynchronizedView<T, TView>(CreateView(transform), collectionEventDispatcher);
|
||||
}
|
||||
|
||||
internal sealed class View<TView> : ISynchronizedView<T, TView>
|
||||
{
|
||||
public ISynchronizedViewFilter<T> Filter
|
||||
|
Loading…
x
Reference in New Issue
Block a user