IHasImages.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. using MediaBrowser.Controller.Providers;
  2. using MediaBrowser.Model.Entities;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Threading.Tasks;
  7. namespace MediaBrowser.Controller.Entities
  8. {
  9. public interface IHasImages : IHasProviderIds
  10. {
  11. /// <summary>
  12. /// Gets the name.
  13. /// </summary>
  14. /// <value>The name.</value>
  15. string Name { get; set; }
  16. /// <summary>
  17. /// Gets the path.
  18. /// </summary>
  19. /// <value>The path.</value>
  20. string Path { get; set; }
  21. /// <summary>
  22. /// Gets the identifier.
  23. /// </summary>
  24. /// <value>The identifier.</value>
  25. Guid Id { get; }
  26. /// <summary>
  27. /// Gets the type of the location.
  28. /// </summary>
  29. /// <value>The type of the location.</value>
  30. LocationType LocationType { get; }
  31. /// <summary>
  32. /// Gets the images.
  33. /// </summary>
  34. /// <param name="imageType">Type of the image.</param>
  35. /// <returns>IEnumerable{ItemImageInfo}.</returns>
  36. IEnumerable<ItemImageInfo> GetImages(ImageType imageType);
  37. /// <summary>
  38. /// Gets the image path.
  39. /// </summary>
  40. /// <param name="imageType">Type of the image.</param>
  41. /// <param name="imageIndex">Index of the image.</param>
  42. /// <returns>System.String.</returns>
  43. string GetImagePath(ImageType imageType, int imageIndex);
  44. /// <summary>
  45. /// Gets the image information.
  46. /// </summary>
  47. /// <param name="imageType">Type of the image.</param>
  48. /// <param name="imageIndex">Index of the image.</param>
  49. /// <returns>ItemImageInfo.</returns>
  50. ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex);
  51. /// <summary>
  52. /// Sets the image.
  53. /// </summary>
  54. /// <param name="type">The type.</param>
  55. /// <param name="index">The index.</param>
  56. /// <param name="file">The file.</param>
  57. void SetImagePath(ImageType type, int index, FileSystemInfo file);
  58. /// <summary>
  59. /// Determines whether the specified type has image.
  60. /// </summary>
  61. /// <param name="type">The type.</param>
  62. /// <param name="imageIndex">Index of the image.</param>
  63. /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
  64. bool HasImage(ImageType type, int imageIndex);
  65. /// <summary>
  66. /// Allowses the multiple images.
  67. /// </summary>
  68. /// <param name="type">The type.</param>
  69. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  70. bool AllowsMultipleImages(ImageType type);
  71. /// <summary>
  72. /// Swaps the images.
  73. /// </summary>
  74. /// <param name="type">The type.</param>
  75. /// <param name="index1">The index1.</param>
  76. /// <param name="index2">The index2.</param>
  77. /// <returns>Task.</returns>
  78. Task SwapImages(ImageType type, int index1, int index2);
  79. /// <summary>
  80. /// Gets the display type of the media.
  81. /// </summary>
  82. /// <value>The display type of the media.</value>
  83. string DisplayMediaType { get; set; }
  84. /// <summary>
  85. /// Gets or sets the primary image path.
  86. /// </summary>
  87. /// <value>The primary image path.</value>
  88. string PrimaryImagePath { get; }
  89. /// <summary>
  90. /// Gets the preferred metadata language.
  91. /// </summary>
  92. /// <returns>System.String.</returns>
  93. string GetPreferredMetadataLanguage();
  94. /// <summary>
  95. /// Validates the images and returns true or false indicating if any were removed.
  96. /// </summary>
  97. bool ValidateImages(IDirectoryService directoryService);
  98. /// <summary>
  99. /// Gets a value indicating whether this instance is owned item.
  100. /// </summary>
  101. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  102. bool IsOwnedItem { get; }
  103. /// <summary>
  104. /// Gets the containing folder path.
  105. /// </summary>
  106. /// <value>The containing folder path.</value>
  107. string ContainingFolderPath { get; }
  108. /// <summary>
  109. /// Adds the images.
  110. /// </summary>
  111. /// <param name="imageType">Type of the image.</param>
  112. /// <param name="images">The images.</param>
  113. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  114. bool AddImages(ImageType imageType, IEnumerable<FileSystemInfo> images);
  115. /// <summary>
  116. /// Determines whether [is save local metadata enabled].
  117. /// </summary>
  118. /// <returns><c>true</c> if [is save local metadata enabled]; otherwise, <c>false</c>.</returns>
  119. bool IsSaveLocalMetadataEnabled();
  120. /// <summary>
  121. /// Gets a value indicating whether [supports local metadata].
  122. /// </summary>
  123. /// <value><c>true</c> if [supports local metadata]; otherwise, <c>false</c>.</value>
  124. bool SupportsLocalMetadata { get; }
  125. /// <summary>
  126. /// Gets a value indicating whether this instance is in mixed folder.
  127. /// </summary>
  128. /// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
  129. bool IsInMixedFolder { get; }
  130. /// <summary>
  131. /// Gets a value indicating whether this instance is locked.
  132. /// </summary>
  133. /// <value><c>true</c> if this instance is locked; otherwise, <c>false</c>.</value>
  134. bool IsLocked { get; }
  135. }
  136. public static class HasImagesExtensions
  137. {
  138. /// <summary>
  139. /// Gets the image path.
  140. /// </summary>
  141. /// <param name="item">The item.</param>
  142. /// <param name="imageType">Type of the image.</param>
  143. /// <returns>System.String.</returns>
  144. public static string GetImagePath(this IHasImages item, ImageType imageType)
  145. {
  146. return item.GetImagePath(imageType, 0);
  147. }
  148. public static bool HasImage(this IHasImages item, ImageType imageType)
  149. {
  150. return item.HasImage(imageType, 0);
  151. }
  152. /// <summary>
  153. /// Sets the image path.
  154. /// </summary>
  155. /// <param name="item">The item.</param>
  156. /// <param name="imageType">Type of the image.</param>
  157. /// <param name="file">The file.</param>
  158. public static void SetImagePath(this IHasImages item, ImageType imageType, FileSystemInfo file)
  159. {
  160. item.SetImagePath(imageType, 0, file);
  161. }
  162. /// <summary>
  163. /// Sets the image path.
  164. /// </summary>
  165. /// <param name="item">The item.</param>
  166. /// <param name="imageType">Type of the image.</param>
  167. /// <param name="file">The file.</param>
  168. public static void SetImagePath(this IHasImages item, ImageType imageType, string file)
  169. {
  170. item.SetImagePath(imageType, new FileInfo(file));
  171. }
  172. }
  173. }