BudgetComparer.cs 882 B

12345678910111213141516171819202122232425262728293031323334
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.Sorting;
  3. using MediaBrowser.Model.Querying;
  4. namespace MediaBrowser.Server.Implementations.Sorting
  5. {
  6. public class BudgetComparer : 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. private double GetValue(BaseItem x)
  19. {
  20. return x.Budget ?? 0;
  21. }
  22. /// <summary>
  23. /// Gets the name.
  24. /// </summary>
  25. /// <value>The name.</value>
  26. public string Name
  27. {
  28. get { return ItemSortBy.Budget; }
  29. }
  30. }
  31. }