From 52aeb3c40b3e2f0fdc377ac7c793714add2be0ef Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 7 Aug 2017 17:06:13 -0400 Subject: consolidate interfaces --- MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- MediaBrowser.Controller/Entities/IHasImages.cs | 260 ----------------------- MediaBrowser.Controller/Entities/IHasMetadata.cs | 253 +++++++++++++++++++++- 3 files changed, 253 insertions(+), 262 deletions(-) delete mode 100644 MediaBrowser.Controller/Entities/IHasImages.cs (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index cb345439a5..7c375b9373 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -39,7 +39,7 @@ namespace MediaBrowser.Controller.Entities /// /// Class BaseItem /// - public abstract class BaseItem : IHasProviderIds, IHasImages, IHasUserData, IHasMetadata, IHasLookupInfo + public abstract class BaseItem : IHasMetadata, IHasLookupInfo { protected BaseItem() { diff --git a/MediaBrowser.Controller/Entities/IHasImages.cs b/MediaBrowser.Controller/Entities/IHasImages.cs deleted file mode 100644 index 6d56b1525f..0000000000 --- a/MediaBrowser.Controller/Entities/IHasImages.cs +++ /dev/null @@ -1,260 +0,0 @@ -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Entities; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.IO; - -namespace MediaBrowser.Controller.Entities -{ - public interface IHasImages : IHasProviderIds, IHasUserData - { - /// - /// Gets the name. - /// - /// The name. - string Name { get; set; } - - /// - /// Gets the path. - /// - /// The path. - string Path { get; set; } - - /// - /// Gets the file name without extension. - /// - /// The file name without extension. - string FileNameWithoutExtension { get; } - - /// - /// Gets the type of the location. - /// - /// The type of the location. - LocationType LocationType { get; } - - /// - /// Gets the locked fields. - /// - /// The locked fields. - List LockedFields { get; } - - /// - /// Gets the images. - /// - /// Type of the image. - /// IEnumerable{ItemImageInfo}. - IEnumerable GetImages(ImageType imageType); - - /// - /// Gets the image path. - /// - /// Type of the image. - /// Index of the image. - /// System.String. - string GetImagePath(ImageType imageType, int imageIndex); - - /// - /// Gets the image information. - /// - /// Type of the image. - /// Index of the image. - /// ItemImageInfo. - ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex); - - /// - /// Sets the image. - /// - /// The type. - /// The index. - /// The file. - void SetImagePath(ImageType type, int index, FileSystemMetadata file); - - /// - /// Determines whether the specified type has image. - /// - /// The type. - /// Index of the image. - /// true if the specified type has image; otherwise, false. - bool HasImage(ImageType type, int imageIndex); - - /// - /// Allowses the multiple images. - /// - /// The type. - /// true if XXXX, false otherwise. - bool AllowsMultipleImages(ImageType type); - - /// - /// Swaps the images. - /// - /// The type. - /// The index1. - /// The index2. - /// Task. - Task SwapImages(ImageType type, int index1, int index2); - - /// - /// Gets or sets the primary image path. - /// - /// The primary image path. - string PrimaryImagePath { get; } - - /// - /// Gets the preferred metadata language. - /// - /// System.String. - string GetPreferredMetadataLanguage(); - - /// - /// Validates the images and returns true or false indicating if any were removed. - /// - bool ValidateImages(IDirectoryService directoryService); - - /// - /// Gets a value indicating whether this instance is owned item. - /// - /// true if this instance is owned item; otherwise, false. - bool IsOwnedItem { get; } - - /// - /// Gets the containing folder path. - /// - /// The containing folder path. - string ContainingFolderPath { get; } - - /// - /// Adds the images. - /// - /// Type of the image. - /// The images. - /// true if XXXX, false otherwise. - bool AddImages(ImageType imageType, List images); - - /// - /// Determines whether [is save local metadata enabled]. - /// - /// true if [is save local metadata enabled]; otherwise, false. - bool IsSaveLocalMetadataEnabled(); - - /// - /// Gets a value indicating whether [supports local metadata]. - /// - /// true if [supports local metadata]; otherwise, false. - bool SupportsLocalMetadata { get; } - - bool IsInMixedFolder { get; } - - /// - /// Gets a value indicating whether this instance is locked. - /// - /// true if this instance is locked; otherwise, false. - bool IsLocked { get; } - - /// - /// Gets a value indicating whether [supports remote image downloading]. - /// - /// true if [supports remote image downloading]; otherwise, false. - bool SupportsRemoteImageDownloading { get; } - - /// - /// Gets the internal metadata path. - /// - /// System.String. - string GetInternalMetadataPath(); - - /// - /// Gets a value indicating whether [always scan internal metadata path]. - /// - /// true if [always scan internal metadata path]; otherwise, false. - bool AlwaysScanInternalMetadataPath { get; } - - /// - /// Determines whether [is internet metadata enabled]. - /// - /// true if [is internet metadata enabled]; otherwise, false. - bool IsInternetMetadataEnabled(); - - /// - /// Removes the image. - /// - /// The image. - void RemoveImage(ItemImageInfo image); - - /// - /// Updates to repository. - /// - /// The update reason. - /// The cancellation token. - /// Task. - Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken); - - /// - /// Sets the image. - /// - /// The image. - /// The index. - void SetImage(ItemImageInfo image, int index); - - double? GetDefaultPrimaryImageAspectRatio(); - - int? ProductionYear { get; set; } - - List Tags { get; set; } - } - - public static class HasImagesExtensions - { - /// - /// Gets the image path. - /// - /// The item. - /// Type of the image. - /// System.String. - public static string GetImagePath(this IHasImages item, ImageType imageType) - { - return item.GetImagePath(imageType, 0); - } - - public static bool HasImage(this IHasImages item, ImageType imageType) - { - return item.HasImage(imageType, 0); - } - - /// - /// Sets the image path. - /// - /// The item. - /// Type of the image. - /// The file. - public static void SetImagePath(this IHasImages item, ImageType imageType, FileSystemMetadata file) - { - item.SetImagePath(imageType, 0, file); - } - - /// - /// Sets the image path. - /// - /// The item. - /// Type of the image. - /// The file. - public static void SetImagePath(this IHasImages item, ImageType imageType, string file) - { - if (file.StartsWith("http", System.StringComparison.OrdinalIgnoreCase)) - { - item.SetImage(new ItemImageInfo - { - Path = file, - Type = imageType - }, 0); - } - else - { - item.SetImagePath(imageType, BaseItem.FileSystem.GetFileInfo(file)); - } - } - } -} diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index 1d2e23a6cf..a76f2fec34 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -1,12 +1,18 @@ using System; using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.Entities { /// /// Interface IHasMetadata /// - public interface IHasMetadata : IHasImages + public interface IHasMetadata : IHasProviderIds, IHasUserData { /// /// Gets the preferred metadata country code. @@ -65,5 +71,250 @@ namespace MediaBrowser.Controller.Entities int InheritedParentalRatingValue { get; set; } List GetInheritedTags(); long? RunTimeTicks { get; set; } + + /// + /// Gets the name. + /// + /// The name. + string Name { get; set; } + + /// + /// Gets the path. + /// + /// The path. + string Path { get; set; } + + /// + /// Gets the file name without extension. + /// + /// The file name without extension. + string FileNameWithoutExtension { get; } + + /// + /// Gets the type of the location. + /// + /// The type of the location. + LocationType LocationType { get; } + + /// + /// Gets the locked fields. + /// + /// The locked fields. + List LockedFields { get; } + + /// + /// Gets the images. + /// + /// Type of the image. + /// IEnumerable{ItemImageInfo}. + IEnumerable GetImages(ImageType imageType); + + /// + /// Gets the image path. + /// + /// Type of the image. + /// Index of the image. + /// System.String. + string GetImagePath(ImageType imageType, int imageIndex); + + /// + /// Gets the image information. + /// + /// Type of the image. + /// Index of the image. + /// ItemImageInfo. + ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex); + + /// + /// Sets the image. + /// + /// The type. + /// The index. + /// The file. + void SetImagePath(ImageType type, int index, FileSystemMetadata file); + + /// + /// Determines whether the specified type has image. + /// + /// The type. + /// Index of the image. + /// true if the specified type has image; otherwise, false. + bool HasImage(ImageType type, int imageIndex); + + /// + /// Allowses the multiple images. + /// + /// The type. + /// true if XXXX, false otherwise. + bool AllowsMultipleImages(ImageType type); + + /// + /// Swaps the images. + /// + /// The type. + /// The index1. + /// The index2. + /// Task. + Task SwapImages(ImageType type, int index1, int index2); + + /// + /// Gets or sets the primary image path. + /// + /// The primary image path. + string PrimaryImagePath { get; } + + /// + /// Gets the preferred metadata language. + /// + /// System.String. + string GetPreferredMetadataLanguage(); + + /// + /// Validates the images and returns true or false indicating if any were removed. + /// + bool ValidateImages(IDirectoryService directoryService); + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + bool IsOwnedItem { get; } + + /// + /// Gets the containing folder path. + /// + /// The containing folder path. + string ContainingFolderPath { get; } + + /// + /// Adds the images. + /// + /// Type of the image. + /// The images. + /// true if XXXX, false otherwise. + bool AddImages(ImageType imageType, List images); + + /// + /// Determines whether [is save local metadata enabled]. + /// + /// true if [is save local metadata enabled]; otherwise, false. + bool IsSaveLocalMetadataEnabled(); + + /// + /// Gets a value indicating whether [supports local metadata]. + /// + /// true if [supports local metadata]; otherwise, false. + bool SupportsLocalMetadata { get; } + + bool IsInMixedFolder { get; } + + /// + /// Gets a value indicating whether this instance is locked. + /// + /// true if this instance is locked; otherwise, false. + bool IsLocked { get; } + + /// + /// Gets a value indicating whether [supports remote image downloading]. + /// + /// true if [supports remote image downloading]; otherwise, false. + bool SupportsRemoteImageDownloading { get; } + + /// + /// Gets the internal metadata path. + /// + /// System.String. + string GetInternalMetadataPath(); + + /// + /// Gets a value indicating whether [always scan internal metadata path]. + /// + /// true if [always scan internal metadata path]; otherwise, false. + bool AlwaysScanInternalMetadataPath { get; } + + /// + /// Determines whether [is internet metadata enabled]. + /// + /// true if [is internet metadata enabled]; otherwise, false. + bool IsInternetMetadataEnabled(); + + /// + /// Removes the image. + /// + /// The image. + void RemoveImage(ItemImageInfo image); + + /// + /// Updates to repository. + /// + /// The update reason. + /// The cancellation token. + /// Task. + Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken); + + /// + /// Sets the image. + /// + /// The image. + /// The index. + void SetImage(ItemImageInfo image, int index); + + double? GetDefaultPrimaryImageAspectRatio(); + + int? ProductionYear { get; set; } + + List Tags { get; set; } + } + + public static class HasMetadataExtensions + { + /// + /// Gets the image path. + /// + /// The item. + /// Type of the image. + /// System.String. + public static string GetImagePath(this IHasMetadata item, ImageType imageType) + { + return item.GetImagePath(imageType, 0); + } + + public static bool HasImage(this IHasMetadata item, ImageType imageType) + { + return item.HasImage(imageType, 0); + } + + /// + /// Sets the image path. + /// + /// The item. + /// Type of the image. + /// The file. + public static void SetImagePath(this IHasMetadata item, ImageType imageType, FileSystemMetadata file) + { + item.SetImagePath(imageType, 0, file); + } + + /// + /// Sets the image path. + /// + /// The item. + /// Type of the image. + /// The file. + public static void SetImagePath(this IHasMetadata item, ImageType imageType, string file) + { + if (file.StartsWith("http", System.StringComparison.OrdinalIgnoreCase)) + { + item.SetImage(new ItemImageInfo + { + Path = file, + Type = imageType + }, 0); + } + else + { + item.SetImagePath(imageType, BaseItem.FileSystem.GetFileInfo(file)); + } + } } } -- cgit v1.2.3