PlayersComparer.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.Sorting;
  3. using MediaBrowser.Model.Querying;
  4. namespace Emby.Server.Implementations.Sorting
  5. {
  6. public class PlayersComparer : IBaseItemComparer
  7. {
  8. /// <summary>
  9. /// Compares the specified x.
  10. /// </summary>
  11. /// <param name="x">The x.</param>
  12. /// <param name="y">The y.</param>
  13. /// <returns>System.Int32.</returns>
  14. public int Compare(BaseItem x, BaseItem y)
  15. {
  16. return GetValue(x).CompareTo(GetValue(y));
  17. }
  18. /// <summary>
  19. /// Gets the value.
  20. /// </summary>
  21. /// <param name="x">The x.</param>
  22. /// <returns>System.String.</returns>
  23. private static int GetValue(BaseItem x)
  24. {
  25. var game = x as Game;
  26. if (game != null)
  27. {
  28. return game.PlayersSupported ?? 0;
  29. }
  30. return 0;
  31. }
  32. /// <summary>
  33. /// Gets the name.
  34. /// </summary>
  35. /// <value>The name.</value>
  36. public string Name => ItemSortBy.Players;
  37. }
  38. }