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