2
0

StudioComparer.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Linq;
  4. using MediaBrowser.Controller.Entities;
  5. using MediaBrowser.Controller.Sorting;
  6. using MediaBrowser.Model.Querying;
  7. namespace Emby.Server.Implementations.Sorting
  8. {
  9. public class StudioComparer : 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. if (x == null)
  20. {
  21. throw new ArgumentNullException(nameof(x));
  22. }
  23. if (y == null)
  24. {
  25. throw new ArgumentNullException(nameof(y));
  26. }
  27. return AlphanumComparator.CompareValues(x.Studios.FirstOrDefault() ?? string.Empty, y.Studios.FirstOrDefault() ?? string.Empty);
  28. }
  29. /// <summary>
  30. /// Gets the name.
  31. /// </summary>
  32. /// <value>The name.</value>
  33. public string Name => ItemSortBy.Studio;
  34. }
  35. }