AudioBookFileInfo.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. namespace Emby.Naming.AudioBook
  3. {
  4. /// <summary>
  5. /// Represents a single video file.
  6. /// </summary>
  7. public class AudioBookFileInfo : IComparable<AudioBookFileInfo>
  8. {
  9. /// <summary>
  10. /// Gets or sets the path.
  11. /// </summary>
  12. /// <value>The path.</value>
  13. public string Path { get; set; }
  14. /// <summary>
  15. /// Gets or sets the container.
  16. /// </summary>
  17. /// <value>The container.</value>
  18. public string Container { get; set; }
  19. /// <summary>
  20. /// Gets or sets the part number.
  21. /// </summary>
  22. /// <value>The part number.</value>
  23. public int? PartNumber { get; set; }
  24. /// <summary>
  25. /// Gets or sets the chapter number.
  26. /// </summary>
  27. /// <value>The chapter number.</value>
  28. public int? ChapterNumber { get; set; }
  29. /// <summary>
  30. /// Gets or sets a value indicating whether this instance is a directory.
  31. /// </summary>
  32. /// <value>The type.</value>
  33. public bool IsDirectory { get; set; }
  34. /// <inheritdoc />
  35. public int CompareTo(AudioBookFileInfo other)
  36. {
  37. if (ReferenceEquals(this, other))
  38. {
  39. return 0;
  40. }
  41. if (ReferenceEquals(null, other))
  42. {
  43. return 1;
  44. }
  45. var chapterNumberComparison = Nullable.Compare(ChapterNumber, other.ChapterNumber);
  46. if (chapterNumberComparison != 0)
  47. {
  48. return chapterNumberComparison;
  49. }
  50. var partNumberComparison = Nullable.Compare(PartNumber, other.PartNumber);
  51. if (partNumberComparison != 0)
  52. {
  53. return partNumberComparison;
  54. }
  55. return string.Compare(Path, other.Path, StringComparison.Ordinal);
  56. }
  57. }
  58. }