2
0

RuntimeComparer.cs 1006 B

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