IHasImages.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using MediaBrowser.Model.Entities;
  2. using System;
  3. using System.Threading.Tasks;
  4. namespace MediaBrowser.Controller.Entities
  5. {
  6. public interface IHasImages
  7. {
  8. /// <summary>
  9. /// Gets the name.
  10. /// </summary>
  11. /// <value>The name.</value>
  12. string Name { get; }
  13. /// <summary>
  14. /// Gets the path.
  15. /// </summary>
  16. /// <value>The path.</value>
  17. string Path { get; set; }
  18. /// <summary>
  19. /// Gets the identifier.
  20. /// </summary>
  21. /// <value>The identifier.</value>
  22. Guid Id { get; }
  23. /// <summary>
  24. /// Gets the image path.
  25. /// </summary>
  26. /// <param name="imageType">Type of the image.</param>
  27. /// <param name="imageIndex">Index of the image.</param>
  28. /// <returns>System.String.</returns>
  29. string GetImagePath(ImageType imageType, int imageIndex);
  30. /// <summary>
  31. /// Gets the image date modified.
  32. /// </summary>
  33. /// <param name="imagePath">The image path.</param>
  34. /// <returns>DateTime.</returns>
  35. DateTime GetImageDateModified(string imagePath);
  36. /// <summary>
  37. /// Sets the image.
  38. /// </summary>
  39. /// <param name="type">The type.</param>
  40. /// <param name="index">The index.</param>
  41. /// <param name="path">The path.</param>
  42. void SetImagePath(ImageType type, int index, string path);
  43. /// <summary>
  44. /// Determines whether the specified type has image.
  45. /// </summary>
  46. /// <param name="type">The type.</param>
  47. /// <param name="imageIndex">Index of the image.</param>
  48. /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
  49. bool HasImage(ImageType type, int imageIndex);
  50. /// <summary>
  51. /// Swaps the images.
  52. /// </summary>
  53. /// <param name="type">The type.</param>
  54. /// <param name="index1">The index1.</param>
  55. /// <param name="index2">The index2.</param>
  56. /// <returns>Task.</returns>
  57. Task SwapImages(ImageType type, int index1, int index2);
  58. /// <summary>
  59. /// Gets the display type of the media.
  60. /// </summary>
  61. /// <value>The display type of the media.</value>
  62. string DisplayMediaType { get; set; }
  63. /// <summary>
  64. /// Gets or sets the primary image path.
  65. /// </summary>
  66. /// <value>The primary image path.</value>
  67. string PrimaryImagePath { get; set; }
  68. /// <summary>
  69. /// Gets the preferred metadata language.
  70. /// </summary>
  71. /// <returns>System.String.</returns>
  72. string GetPreferredMetadataLanguage();
  73. }
  74. public static class HasImagesExtensions
  75. {
  76. /// <summary>
  77. /// Gets the image path.
  78. /// </summary>
  79. /// <param name="item">The item.</param>
  80. /// <param name="imageType">Type of the image.</param>
  81. /// <returns>System.String.</returns>
  82. public static string GetImagePath(this IHasImages item, ImageType imageType)
  83. {
  84. return item.GetImagePath(imageType, 0);
  85. }
  86. public static bool HasImage(this IHasImages item, ImageType imageType)
  87. {
  88. return item.HasImage(imageType, 0);
  89. }
  90. /// <summary>
  91. /// Sets the image path.
  92. /// </summary>
  93. /// <param name="item">The item.</param>
  94. /// <param name="imageType">Type of the image.</param>
  95. /// <param name="path">The path.</param>
  96. public static void SetImagePath(this IHasImages item, ImageType imageType, string path)
  97. {
  98. item.SetImagePath(imageType, 0, path);
  99. }
  100. }
  101. }