RuntimeComparer.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #nullable disable
  2. using System;
  3. using MediaBrowser.Controller.Entities;
  4. using MediaBrowser.Controller.Sorting;
  5. using MediaBrowser.Model.Querying;
  6. namespace Emby.Server.Implementations.Sorting
  7. {
  8. /// <summary>
  9. /// Class RuntimeComparer.
  10. /// </summary>
  11. public class RuntimeComparer : IBaseItemComparer
  12. {
  13. /// <summary>
  14. /// Compares the specified x.
  15. /// </summary>
  16. /// <param name="x">The x.</param>
  17. /// <param name="y">The y.</param>
  18. /// <returns>System.Int32.</returns>
  19. public int Compare(BaseItem x, BaseItem y)
  20. {
  21. if (x == null)
  22. {
  23. throw new ArgumentNullException(nameof(x));
  24. }
  25. if (y == null)
  26. {
  27. throw new ArgumentNullException(nameof(y));
  28. }
  29. return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);
  30. }
  31. /// <summary>
  32. /// Gets the name.
  33. /// </summary>
  34. /// <value>The name.</value>
  35. public string Name => ItemSortBy.Runtime;
  36. }
  37. }