StudioComparer.cs 1022 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Linq;
  3. using MediaBrowser.Controller.Entities;
  4. using MediaBrowser.Controller.Sorting;
  5. using MediaBrowser.Model.Querying;
  6. namespace Emby.Server.Implementations.Sorting
  7. {
  8. public class StudioComparer : IBaseItemComparer
  9. {
  10. /// <summary>
  11. /// Compares the specified x.
  12. /// </summary>
  13. /// <param name="x">The x.</param>
  14. /// <param name="y">The y.</param>
  15. /// <returns>System.Int32.</returns>
  16. public int Compare(BaseItem x, BaseItem y)
  17. {
  18. if (x == null)
  19. throw new ArgumentNullException(nameof(x));
  20. if (y == null)
  21. throw new ArgumentNullException(nameof(y));
  22. return AlphanumComparator.CompareValues(x.Studios.FirstOrDefault() ?? string.Empty, y.Studios.FirstOrDefault() ?? string.Empty);
  23. }
  24. /// <summary>
  25. /// Gets the name.
  26. /// </summary>
  27. /// <value>The name.</value>
  28. public string Name => ItemSortBy.Studio;
  29. }
  30. }