CommunityRatingComparer.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma warning disable CS1591
  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. public class CommunityRatingComparer : IBaseItemComparer
  9. {
  10. /// <summary>
  11. /// Gets the name.
  12. /// </summary>
  13. /// <value>The name.</value>
  14. public string Name => ItemSortBy.CommunityRating;
  15. /// <summary>
  16. /// Compares the specified x.
  17. /// </summary>
  18. /// <param name="x">The x.</param>
  19. /// <param name="y">The y.</param>
  20. /// <returns>System.Int32.</returns>
  21. public int Compare(BaseItem? x, BaseItem? y)
  22. {
  23. if (x == null)
  24. {
  25. throw new ArgumentNullException(nameof(x));
  26. }
  27. if (y == null)
  28. {
  29. throw new ArgumentNullException(nameof(y));
  30. }
  31. return (x.CommunityRating ?? 0).CompareTo(y.CommunityRating ?? 0);
  32. }
  33. }
  34. }