IsFolderComparer.cs 1.0 KB

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