#pragma warning disable CS1591 using System; using System.Collections.Generic; using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Entities { public interface IHasTrailers : IHasProviderIds { /// /// Gets or sets the remote trailers. /// /// The remote trailers. IReadOnlyList RemoteTrailers { get; set; } /// /// Gets or sets the local trailer ids. /// /// The local trailer ids. IReadOnlyList LocalTrailerIds { get; set; } /// /// Gets or sets the remote trailer ids. /// /// The remote trailer ids. IReadOnlyList RemoteTrailerIds { get; set; } Guid Id { get; set; } } /// /// Class providing extension methods for working with . /// public static class HasTrailerExtensions { /// /// Gets the trailer count. /// /// . public static int GetTrailerCount(this IHasTrailers item) => item.LocalTrailerIds.Count + item.RemoteTrailerIds.Count; /// /// Gets the trailer ids. /// /// . public static IReadOnlyList GetTrailerIds(this IHasTrailers item) { var localIds = item.LocalTrailerIds; var remoteIds = item.RemoteTrailerIds; var all = new Guid[localIds.Count + remoteIds.Count]; var index = 0; foreach (var id in localIds) { all[index++] = id; } foreach (var id in remoteIds) { all[index++] = id; } return all; } /// /// Gets the trailers. /// /// . public static IReadOnlyList GetTrailers(this IHasTrailers item) { var localIds = item.LocalTrailerIds; var remoteIds = item.RemoteTrailerIds; var libraryManager = BaseItem.LibraryManager; var all = new BaseItem[localIds.Count + remoteIds.Count]; var index = 0; foreach (var id in localIds) { all[index++] = libraryManager.GetItemById(id); } foreach (var id in remoteIds) { all[index++] = libraryManager.GetItemById(id); } return all; } } }