IHasImages.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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; }
  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. }
  59. public static class HasImagesExtensions
  60. {
  61. /// <summary>
  62. /// Gets the image path.
  63. /// </summary>
  64. /// <param name="item">The item.</param>
  65. /// <param name="imageType">Type of the image.</param>
  66. /// <returns>System.String.</returns>
  67. public static string GetImagePath(this IHasImages item, ImageType imageType)
  68. {
  69. return item.GetImagePath(imageType, 0);
  70. }
  71. public static bool HasImage(this IHasImages item, ImageType imageType)
  72. {
  73. return item.HasImage(imageType, 0);
  74. }
  75. /// <summary>
  76. /// Sets the image path.
  77. /// </summary>
  78. /// <param name="item">The item.</param>
  79. /// <param name="imageType">Type of the image.</param>
  80. /// <param name="path">The path.</param>
  81. public static void SetImagePath(this IHasImages item, ImageType imageType, string path)
  82. {
  83. item.SetImagePath(imageType, 0, path);
  84. }
  85. }
  86. }