IHasImages.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 locked fields.
  33. /// </summary>
  34. /// <value>The locked fields.</value>
  35. List<MetadataFields> LockedFields { get; }
  36. /// <summary>
  37. /// Gets the images.
  38. /// </summary>
  39. /// <param name="imageType">Type of the image.</param>
  40. /// <returns>IEnumerable{ItemImageInfo}.</returns>
  41. IEnumerable<ItemImageInfo> GetImages(ImageType imageType);
  42. /// <summary>
  43. /// Gets the image path.
  44. /// </summary>
  45. /// <param name="imageType">Type of the image.</param>
  46. /// <param name="imageIndex">Index of the image.</param>
  47. /// <returns>System.String.</returns>
  48. string GetImagePath(ImageType imageType, int imageIndex);
  49. /// <summary>
  50. /// Gets the image information.
  51. /// </summary>
  52. /// <param name="imageType">Type of the image.</param>
  53. /// <param name="imageIndex">Index of the image.</param>
  54. /// <returns>ItemImageInfo.</returns>
  55. ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex);
  56. /// <summary>
  57. /// Sets the image.
  58. /// </summary>
  59. /// <param name="type">The type.</param>
  60. /// <param name="index">The index.</param>
  61. /// <param name="file">The file.</param>
  62. void SetImagePath(ImageType type, int index, FileSystemInfo file);
  63. /// <summary>
  64. /// Determines whether the specified type has image.
  65. /// </summary>
  66. /// <param name="type">The type.</param>
  67. /// <param name="imageIndex">Index of the image.</param>
  68. /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
  69. bool HasImage(ImageType type, int imageIndex);
  70. /// <summary>
  71. /// Allowses the multiple images.
  72. /// </summary>
  73. /// <param name="type">The type.</param>
  74. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  75. bool AllowsMultipleImages(ImageType type);
  76. /// <summary>
  77. /// Swaps the images.
  78. /// </summary>
  79. /// <param name="type">The type.</param>
  80. /// <param name="index1">The index1.</param>
  81. /// <param name="index2">The index2.</param>
  82. /// <returns>Task.</returns>
  83. Task SwapImages(ImageType type, int index1, int index2);
  84. /// <summary>
  85. /// Gets the display type of the media.
  86. /// </summary>
  87. /// <value>The display type of the media.</value>
  88. string DisplayMediaType { get; set; }
  89. /// <summary>
  90. /// Gets or sets the primary image path.
  91. /// </summary>
  92. /// <value>The primary image path.</value>
  93. string PrimaryImagePath { get; }
  94. /// <summary>
  95. /// Gets the preferred metadata language.
  96. /// </summary>
  97. /// <returns>System.String.</returns>
  98. string GetPreferredMetadataLanguage();
  99. /// <summary>
  100. /// Validates the images and returns true or false indicating if any were removed.
  101. /// </summary>
  102. bool ValidateImages(IDirectoryService directoryService);
  103. /// <summary>
  104. /// Gets a value indicating whether this instance is owned item.
  105. /// </summary>
  106. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  107. bool IsOwnedItem { get; }
  108. /// <summary>
  109. /// Gets the containing folder path.
  110. /// </summary>
  111. /// <value>The containing folder path.</value>
  112. string ContainingFolderPath { get; }
  113. /// <summary>
  114. /// Adds the images.
  115. /// </summary>
  116. /// <param name="imageType">Type of the image.</param>
  117. /// <param name="images">The images.</param>
  118. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  119. bool AddImages(ImageType imageType, IEnumerable<FileSystemInfo> images);
  120. /// <summary>
  121. /// Determines whether [is save local metadata enabled].
  122. /// </summary>
  123. /// <returns><c>true</c> if [is save local metadata enabled]; otherwise, <c>false</c>.</returns>
  124. bool IsSaveLocalMetadataEnabled();
  125. /// <summary>
  126. /// Gets a value indicating whether [supports local metadata].
  127. /// </summary>
  128. /// <value><c>true</c> if [supports local metadata]; otherwise, <c>false</c>.</value>
  129. bool SupportsLocalMetadata { get; }
  130. /// <summary>
  131. /// Gets a value indicating whether this instance is in mixed folder.
  132. /// </summary>
  133. /// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
  134. bool IsInMixedFolder { get; }
  135. /// <summary>
  136. /// Gets a value indicating whether this instance is locked.
  137. /// </summary>
  138. /// <value><c>true</c> if this instance is locked; otherwise, <c>false</c>.</value>
  139. bool IsLocked { get; }
  140. /// <summary>
  141. /// Gets a value indicating whether [supports remote image downloading].
  142. /// </summary>
  143. /// <value><c>true</c> if [supports remote image downloading]; otherwise, <c>false</c>.</value>
  144. bool SupportsRemoteImageDownloading { get; }
  145. /// <summary>
  146. /// Gets the internal metadata path.
  147. /// </summary>
  148. /// <returns>System.String.</returns>
  149. string GetInternalMetadataPath();
  150. }
  151. public static class HasImagesExtensions
  152. {
  153. /// <summary>
  154. /// Gets the image path.
  155. /// </summary>
  156. /// <param name="item">The item.</param>
  157. /// <param name="imageType">Type of the image.</param>
  158. /// <returns>System.String.</returns>
  159. public static string GetImagePath(this IHasImages item, ImageType imageType)
  160. {
  161. return item.GetImagePath(imageType, 0);
  162. }
  163. public static bool HasImage(this IHasImages item, ImageType imageType)
  164. {
  165. return item.HasImage(imageType, 0);
  166. }
  167. /// <summary>
  168. /// Sets the image path.
  169. /// </summary>
  170. /// <param name="item">The item.</param>
  171. /// <param name="imageType">Type of the image.</param>
  172. /// <param name="file">The file.</param>
  173. public static void SetImagePath(this IHasImages item, ImageType imageType, FileSystemInfo file)
  174. {
  175. item.SetImagePath(imageType, 0, file);
  176. }
  177. /// <summary>
  178. /// Sets the image path.
  179. /// </summary>
  180. /// <param name="item">The item.</param>
  181. /// <param name="imageType">Type of the image.</param>
  182. /// <param name="file">The file.</param>
  183. public static void SetImagePath(this IHasImages item, ImageType imageType, string file)
  184. {
  185. item.SetImagePath(imageType, new FileInfo(file));
  186. }
  187. }
  188. }