RuntimeComparer.cs 933 B

123456789101112131415161718192021222324252627282930313233
  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. /// Gets the name.
  14. /// </summary>
  15. /// <value>The name.</value>
  16. public string Name => ItemSortBy.Runtime;
  17. /// <summary>
  18. /// Compares the specified x.
  19. /// </summary>
  20. /// <param name="x">The x.</param>
  21. /// <param name="y">The y.</param>
  22. /// <returns>System.Int32.</returns>
  23. public int Compare(BaseItem? x, BaseItem? y)
  24. {
  25. ArgumentNullException.ThrowIfNull(x);
  26. ArgumentNullException.ThrowIfNull(y);
  27. return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);
  28. }
  29. }
  30. }