DateCreatedComparer.cs 1.0 KB

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