| | 1 | | #pragma warning disable CS1591 |
| | 2 | |
|
| | 3 | | using Jellyfin.Data.Enums; |
| | 4 | | using MediaBrowser.Controller.Entities; |
| | 5 | | using MediaBrowser.Controller.Sorting; |
| | 6 | | using MediaBrowser.Model.Querying; |
| | 7 | |
|
| | 8 | | namespace Emby.Server.Implementations.Sorting |
| | 9 | | { |
| | 10 | | public class IsFolderComparer : IBaseItemComparer |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Gets the name. |
| | 14 | | /// </summary> |
| | 15 | | /// <value>The name.</value> |
| 1 | 16 | | public ItemSortBy Type => ItemSortBy.IsFolder; |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// Compares the specified x. |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="x">The x.</param> |
| | 22 | | /// <param name="y">The y.</param> |
| | 23 | | /// <returns>System.Int32.</returns> |
| | 24 | | public int Compare(BaseItem? x, BaseItem? y) |
| | 25 | | { |
| 0 | 26 | | return GetValue(x).CompareTo(GetValue(y)); |
| | 27 | | } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Gets the value. |
| | 31 | | /// </summary> |
| | 32 | | /// <param name="x">The x.</param> |
| | 33 | | /// <returns>System.String.</returns> |
| | 34 | | private static int GetValue(BaseItem? x) |
| | 35 | | { |
| 0 | 36 | | return x?.IsFolder ?? true ? 0 : 1; |
| | 37 | | } |
| | 38 | | } |
| | 39 | | } |