IsFolderComparer.cs 1.1 KB

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