CriticRatingComparer.cs 928 B

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