| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ExpressionSortingProperty.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using System.ComponentModel; |
| | | 9 | | using System.Linq.Expressions; |
| | | 10 | | |
| | | 11 | | namespace MyNet.Observable.Collections.Sorting; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Represents a sorting property defined by an expression, along with the sorting direction. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <param name="expression">The expression that defines the sorting property.</param> |
| | | 17 | | /// <param name="direction">The direction in which to sort the items.</param> |
| | | 18 | | /// <typeparam name="T">The type of the items to be sorted.</typeparam> |
| | | 19 | | public sealed class ExpressionSortingProperty<T>(Expression<Func<T, object?>> expression, ListSortDirection direction = |
| | | 20 | | { |
| | | 21 | | /// <summary> |
| | | 22 | | /// Gets the expression that defines the sorting property. This expression is used to determine the value of the pro |
| | | 23 | | /// </summary> |
| | 30 | 24 | | public Expression<Func<T, object?>> Expression { get; } = expression; |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets the direction in which to sort the items based on this sorting property. The direction can be either ascend |
| | | 28 | | /// </summary> |
| | 30 | 29 | | public ListSortDirection Direction { get; } = direction; |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Provides the expression that defines the sorting property. This method is part of the <see cref="ISortingPropert |
| | | 33 | | /// </summary> |
| | | 34 | | /// <returns>The expression that defines the sorting property.</returns> |
| | 45 | 35 | | public Expression<Func<T, object?>> ProvideExpression() => Expression; |
| | | 36 | | } |
| | | 37 | | |