2
0

SeriesSortNameComparer.cs 1015 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma warning disable CS1591
  2. using System;
  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 SeriesSortNameComparer : IBaseItemComparer
  9. {
  10. /// <summary>
  11. /// Gets the name.
  12. /// </summary>
  13. /// <value>The name.</value>
  14. public string Name => ItemSortBy.SeriesSortName;
  15. /// <summary>
  16. /// Compares the specified x.
  17. /// </summary>
  18. /// <param name="x">The x.</param>
  19. /// <param name="y">The y.</param>
  20. /// <returns>System.Int32.</returns>
  21. public int Compare(BaseItem x, BaseItem y)
  22. {
  23. return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase);
  24. }
  25. private static string GetValue(BaseItem item)
  26. {
  27. var hasSeries = item as IHasSeries;
  28. return hasSeries?.FindSeriesSortName();
  29. }
  30. }
  31. }