IHasImages.cs 4.6 KB

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