| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ExtendedCollectionDataProvider.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using System.Collections.Generic; |
| | | 9 | | using System.Collections.ObjectModel; |
| | | 10 | | using DynamicData; |
| | | 11 | | using MyNet.Observable.Collections; |
| | | 12 | | using MyNet.Observable.Collections.Filters; |
| | | 13 | | using MyNet.Observable.Collections.Grouping; |
| | | 14 | | using MyNet.Observable.Collections.Sorting; |
| | | 15 | | |
| | | 16 | | namespace MyNet.UI.ViewModels.List; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Adapts an <see cref="ExtendedCollection{T}"/> instance to the list view model pipeline abstraction. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <typeparam name="T">The item type.</typeparam> |
| | | 22 | | public sealed class ExtendedCollectionDataProvider<T>(ExtendedCollection<T> collection) : IListDataProvider<T> |
| | | 23 | | where T : notnull |
| | | 24 | | { |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets the adapted collection. |
| | | 27 | | /// </summary> |
| | 63 | 28 | | public ExtendedCollection<T> Collection { get; } = collection ?? throw new ArgumentNullException(nameof(collection)) |
| | | 29 | | |
| | | 30 | | /// <inheritdoc /> |
| | 63 | 31 | | public ReadOnlyObservableCollection<T> Source => Collection.Source; |
| | | 32 | | |
| | | 33 | | /// <inheritdoc /> |
| | 63 | 34 | | public ReadOnlyObservableCollection<T> FilteredItems => Collection.FilteredItems; |
| | | 35 | | |
| | | 36 | | /// <inheritdoc /> |
| | 63 | 37 | | public ReadOnlyObservableCollection<T> Items => Collection.Items; |
| | | 38 | | |
| | | 39 | | /// <inheritdoc /> |
| | 51 | 40 | | public int FilteredCount => Collection.Count; |
| | | 41 | | |
| | | 42 | | /// <inheritdoc /> |
| | 12 | 43 | | public IObservable<IChangeSet<T>> ConnectFiltered() => Collection.ConnectFiltered(); |
| | | 44 | | |
| | | 45 | | /// <inheritdoc /> |
| | 0 | 46 | | public IObservable<IChangeSet<T>> Connect() => Collection.Connect(); |
| | | 47 | | |
| | | 48 | | /// <inheritdoc /> |
| | 63 | 49 | | public IObservable<IReadOnlyList<CollectionGroup<T>>> ConnectGroups() => Collection.ConnectGroups(); |
| | | 50 | | |
| | | 51 | | /// <inheritdoc /> |
| | 6 | 52 | | public void SetFilter(IFilter<T> filter) => Collection.SetFilter(filter); |
| | | 53 | | |
| | | 54 | | /// <inheritdoc /> |
| | 0 | 55 | | public void ClearFilter() => Collection.ClearFilter(); |
| | | 56 | | |
| | | 57 | | /// <inheritdoc /> |
| | 0 | 58 | | public void SetSorting(params ISortingProperty<T>[] sorting) => Collection.SetSorting(sorting); |
| | | 59 | | |
| | | 60 | | /// <inheritdoc /> |
| | 75 | 61 | | public void ClearSorting() => Collection.ClearSorting(); |
| | | 62 | | |
| | | 63 | | /// <inheritdoc /> |
| | 0 | 64 | | public void SetGrouping(params IGroupingProperty<T>[] grouping) => Collection.SetGrouping(grouping); |
| | | 65 | | |
| | | 66 | | /// <inheritdoc /> |
| | 75 | 67 | | public void ClearGrouping() => Collection.ClearGrouping(); |
| | | 68 | | |
| | | 69 | | /// <inheritdoc /> |
| | 51 | 70 | | public void SetPaging(int page, int pageSize) => Collection.SetPaging(page, pageSize); |
| | | 71 | | |
| | | 72 | | /// <inheritdoc /> |
| | 51 | 73 | | public void ClearPaging() => Collection.ClearPaging(); |
| | | 74 | | |
| | | 75 | | /// <inheritdoc /> |
| | 63 | 76 | | public void Dispose() => Collection.Dispose(); |
| | | 77 | | } |
| | | 78 | | |