| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ListViewModel.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Reactive.Concurrency; |
| | | 8 | | using MyNet.Observable.Collections.Sources; |
| | | 9 | | using MyNet.UI.ViewModels.List.Factories; |
| | | 10 | | using MyNet.UI.ViewModels.List.Filtering; |
| | | 11 | | using MyNet.UI.ViewModels.List.Grouping; |
| | | 12 | | using MyNet.UI.ViewModels.List.Paging; |
| | | 13 | | using MyNet.UI.ViewModels.List.Sorting; |
| | | 14 | | |
| | | 15 | | namespace MyNet.UI.ViewModels.List; |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Represents a view model for a list of items of type T, providing functionalities for filtering, sorting, grouping, a |
| | | 19 | | /// </summary> |
| | | 20 | | /// <typeparam name="T">The type of items in the list.</typeparam> |
| | | 21 | | /// <remarks> |
| | | 22 | | /// Initializes a new instance of the <see cref="ListViewModel{T}"/> class with the specified collection and optional vi |
| | | 23 | | /// </remarks> |
| | | 24 | | /// <param name="dataProvider">The collection of items to be managed by the view model.</param> |
| | | 25 | | /// <param name="filters">Optional view model for managing filters.</param> |
| | | 26 | | /// <param name="sorting">Optional view model for managing sorting.</param> |
| | | 27 | | /// <param name="grouping">Optional view model for managing grouping.</param> |
| | | 28 | | /// <param name="paging">Optional view model for managing paging.</param> |
| | | 29 | | /// <param name="scheduler">Optional scheduler for managing concurrency.</param> |
| | | 30 | | public class ListViewModel<T>(IListDataProvider<T> dataProvider, |
| | | 31 | | IFiltersViewModel<T>? filters = null, |
| | | 32 | | ISortingViewModel<T>? sorting = null, |
| | | 33 | | IGroupingViewModel<T>? grouping = null, |
| | | 34 | | IPagingViewModel? paging = null, |
| | 36 | 35 | | IScheduler? scheduler = null) : ListViewModelBase<T>(dataProvider, filters, sorting, grouping, paging, scheduler) |
| | | 36 | | where T : notnull |
| | | 37 | | { |
| | | 38 | | /// <summary> |
| | | 39 | | /// Initializes a new instance of the <see cref="ListViewModel{T}"/> class with optional options. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <param name="source">The collection of items to be managed by the view model.</param> |
| | | 42 | | /// <param name="options">Optional list view model options.</param> |
| | | 43 | | public ListViewModel(SourceEngine<T> source, ListViewModelOptions<T>? options) |
| | 0 | 44 | | : this(new ExtendedCollectionDataProvider<T>(new(source, options?.Scheduler)), options) |
| | | 45 | | { |
| | 0 | 46 | | } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Initializes a new instance of the <see cref="ListViewModel{T}"/> class from a source engine. |
| | | 50 | | /// </summary> |
| | | 51 | | public ListViewModel(SourceEngine<T> source, |
| | | 52 | | IFiltersViewModel<T>? filters = null, |
| | | 53 | | ISortingViewModel<T>? sorting = null, |
| | | 54 | | IGroupingViewModel<T>? grouping = null, |
| | | 55 | | IPagingViewModel? paging = null, |
| | | 56 | | IScheduler? scheduler = null) |
| | 0 | 57 | | : this(new ExtendedCollectionDataProvider<T>(new(source, scheduler)), filters, sorting, grouping, paging, schedu |
| | | 58 | | { |
| | 0 | 59 | | } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Initializes a new instance of the <see cref="ListViewModel{T}"/> class with optional options. |
| | | 63 | | /// </summary> |
| | | 64 | | public ListViewModel(IListDataProvider<T> dataProvider, ListViewModelOptions<T>? options) |
| | 36 | 65 | | : this(dataProvider, options?.Filters, options?.Sorting, options?.Grouping, options?.Paging, options?.Scheduler) |
| | | 66 | | { |
| | 36 | 67 | | } |
| | | 68 | | } |
| | | 69 | | |