IsFolderComparer.cs 1002 B

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