diff options
Diffstat (limited to 'MediaBrowser.Controller')
38 files changed, 215 insertions, 174 deletions
diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs index 29363f492..113f823f5 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Drawing /// Gets the image enhancers. /// </summary> /// <value>The image enhancers.</value> - IEnumerable<IImageEnhancer> ImageEnhancers { get; } + IImageEnhancer[] ImageEnhancers { get; } /// <summary> /// Gets the size of the image. @@ -54,7 +54,7 @@ namespace MediaBrowser.Controller.Drawing /// <param name="item">The item.</param> /// <param name="imageType">Type of the image.</param> /// <returns>IEnumerable{IImageEnhancer}.</returns> - IEnumerable<IImageEnhancer> GetSupportedEnhancers(IHasMetadata item, ImageType imageType); + List<IImageEnhancer> GetSupportedEnhancers(IHasMetadata item, ImageType imageType); /// <summary> /// Gets the image cache tag. diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index db84d6e2f..2105ef907 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities { public AggregateFolder() { - PhysicalLocationsList = new List<string>(); + PhysicalLocationsList = EmptyStringArray; } [IgnoreDataMember] @@ -58,7 +58,7 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public override IEnumerable<string> PhysicalLocations + public override string[] PhysicalLocations { get { @@ -66,23 +66,23 @@ namespace MediaBrowser.Controller.Entities } } - public List<string> PhysicalLocationsList { get; set; } + public string[] PhysicalLocationsList { get; set; } protected override FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService) { - return CreateResolveArgs(directoryService, true).FileSystemChildren.ToArray(); + return CreateResolveArgs(directoryService, true).FileSystemChildren; } - private List<Guid> _childrenIds = null; + private Guid[] _childrenIds = null; private readonly object _childIdsLock = new object(); protected override List<BaseItem> LoadChildren() { lock (_childIdsLock) { - if (_childrenIds == null || _childrenIds.Count == 0) + if (_childrenIds == null || _childrenIds.Length == 0) { - var list = base.LoadChildren().ToList(); - _childrenIds = list.Select(i => i.Id).ToList(); + var list = base.LoadChildren(); + _childrenIds = list.Select(i => i.Id).ToArray(); return list; } @@ -105,9 +105,9 @@ namespace MediaBrowser.Controller.Entities if (!changed) { - var locations = PhysicalLocations.ToList(); + var locations = PhysicalLocations; - var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations.ToList(); + var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations; if (!locations.SequenceEqual(newLocations)) { @@ -163,7 +163,7 @@ namespace MediaBrowser.Controller.Entities _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); if (setPhysicalLocations) { - PhysicalLocationsList = args.PhysicalLocations.ToList(); + PhysicalLocationsList = args.PhysicalLocations; } return args; @@ -212,7 +212,14 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("id"); } - return _virtualChildren.FirstOrDefault(i => i.Id == id); + foreach (var child in _virtualChildren) + { + if (child.Id == id) + { + return child; + } + } + return null; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 0781dc35b..e029a447e 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// </summary> /// <value>The artist.</value> [IgnoreDataMember] - public List<string> Artists { get; set; } + public string[] Artists { get; set; } [IgnoreDataMember] public string[] AlbumArtists { get; set; } @@ -42,7 +42,7 @@ namespace MediaBrowser.Controller.Entities.Audio public Audio() { - Artists = new List<string>(); + Artists = EmptyStringArray; AlbumArtists = EmptyStringArray; } @@ -98,13 +98,23 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] - public List<string> AllArtists + public string[] AllArtists { get { - var list = AlbumArtists.ToList(); + var list = new string[AlbumArtists.Length + Artists.Length]; - list.AddRange(Artists); + var index = 0; + foreach (var artist in AlbumArtists) + { + list[index] = artist; + index++; + } + foreach (var artist in AlbumArtists) + { + list[index] = artist; + index++; + } return list; @@ -160,7 +170,7 @@ namespace MediaBrowser.Controller.Entities.Audio songKey = Album + "-" + songKey; } - var albumArtist = AlbumArtists.FirstOrDefault(); + var albumArtist = AlbumArtists.Length == 0 ? null : AlbumArtists[0]; if (!string.IsNullOrWhiteSpace(albumArtist)) { songKey = albumArtist + "-" + songKey; diff --git a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs index 6900699e5..b2dedada4 100644 --- a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs @@ -1,6 +1,4 @@ -using MediaBrowser.Controller.Library; -using System.Collections.Generic; - + namespace MediaBrowser.Controller.Entities.Audio { public interface IHasAlbumArtist @@ -10,16 +8,8 @@ namespace MediaBrowser.Controller.Entities.Audio public interface IHasArtist { - List<string> AllArtists { get; } - - List<string> Artists { get; set; } - } + string[] AllArtists { get; } - public static class HasArtistExtensions - { - public static bool HasAnyArtist(this IHasArtist hasArtist, string artist) - { - return NameExtensions.EqualsAny(hasArtist.AllArtists, artist); - } + string[] Artists { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index c35e81826..82f880b3f 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -10,7 +10,6 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Dto; namespace MediaBrowser.Controller.Entities.Audio { @@ -20,11 +19,11 @@ namespace MediaBrowser.Controller.Entities.Audio public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasLookupInfo<AlbumInfo>, IMetadataContainer { public string[] AlbumArtists { get; set; } - public List<string> Artists { get; set; } + public string[] Artists { get; set; } public MusicAlbum() { - Artists = new List<string>(); + Artists = EmptyStringArray; AlbumArtists = EmptyStringArray; } @@ -48,17 +47,22 @@ namespace MediaBrowser.Controller.Entities.Audio public MusicArtist GetMusicArtist(DtoOptions options) { - var artist = GetParents().OfType<MusicArtist>().FirstOrDefault(); - - if (artist == null) + var parents = GetParents(); + foreach (var parent in parents) { - var name = AlbumArtist; - if (!string.IsNullOrWhiteSpace(name)) + var artist = parent as MusicArtist; + if (artist != null) { - artist = LibraryManager.GetArtist(name, options); + return artist; } } - return artist; + + var name = AlbumArtist; + if (!string.IsNullOrWhiteSpace(name)) + { + return LibraryManager.GetArtist(name, options); + } + return null; } [IgnoreDataMember] @@ -80,23 +84,32 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] - public List<string> AllArtists + public string[] AllArtists { get { - var list = AlbumArtists.ToList(); + var list = new string[AlbumArtists.Length + Artists.Length]; - list.AddRange(Artists); + var index = 0; + foreach (var artist in AlbumArtists) + { + list[index] = artist; + index++; + } + foreach (var artist in AlbumArtists) + { + list[index] = artist; + index++; + } return list; - } } [IgnoreDataMember] public string AlbumArtist { - get { return AlbumArtists.FirstOrDefault(); } + get { return AlbumArtists.Length == 0 ? null : AlbumArtists[0]; } } [IgnoreDataMember] @@ -110,11 +123,11 @@ namespace MediaBrowser.Controller.Entities.Audio /// </summary> /// <value>The tracks.</value> [IgnoreDataMember] - public IEnumerable<Audio> Tracks + public IEnumerable<BaseItem> Tracks { get { - return GetRecursiveChildren(i => i is Audio).Cast<Audio>(); + return GetRecursiveChildren(i => i is Audio); } } @@ -200,7 +213,7 @@ namespace MediaBrowser.Controller.Entities.Audio public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress<double> progress, CancellationToken cancellationToken) { - var items = GetRecursiveChildren().ToList(); + var items = GetRecursiveChildren(); var totalItems = items.Count; var numComplete = 0; @@ -239,27 +252,22 @@ namespace MediaBrowser.Controller.Entities.Audio private async Task RefreshArtists(MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken) { - var artists = AllArtists.Select(i => + var all = AllArtists; + foreach (var i in all) { // This should not be necessary but we're seeing some cases of it if (string.IsNullOrWhiteSpace(i)) { - return null; + continue; } var artist = LibraryManager.GetArtist(i); if (!artist.IsAccessedByName) { - return null; + continue; } - return artist; - - }).Where(i => i != null).ToList(); - - foreach (var artist in artists) - { await artist.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 559806ac4..19fe68e25 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -214,18 +214,19 @@ namespace MediaBrowser.Controller.Entities.Audio { var items = GetRecursiveChildren(); - var songs = items.OfType<Audio>().ToList(); - - var others = items.Except(songs).ToList(); - - var totalItems = songs.Count + others.Count; + var totalItems = items.Count; var numComplete = 0; var childUpdateType = ItemUpdateType.None; // Refresh songs - foreach (var item in songs) + foreach (var item in items) { + if (!(item is Audio)) + { + continue; + } + cancellationToken.ThrowIfCancellationRequested(); var updateType = await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); @@ -248,8 +249,13 @@ namespace MediaBrowser.Controller.Entities.Audio await RefreshMetadata(parentRefreshOptions, cancellationToken).ConfigureAwait(false); // Refresh all non-songs - foreach (var item in others) + foreach (var item in items) { + if (item is Audio) + { + continue; + } + cancellationToken.ThrowIfCancellationRequested(); var updateType = await item.RefreshMetadata(parentRefreshOptions, cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index d4a85b4d0..02e652048 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index c158378a6..24fa80ef6 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -570,7 +570,7 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public virtual IEnumerable<string> PhysicalLocations + public virtual string[] PhysicalLocations { get { diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs index 7cb242589..9b1a52f83 100644 --- a/MediaBrowser.Controller/Entities/Book.cs +++ b/MediaBrowser.Controller/Entities/Book.cs @@ -1,7 +1,7 @@ using System; +using System.Linq; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Entities; diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 3e2c501b4..537beb26b 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -27,8 +27,8 @@ namespace MediaBrowser.Controller.Entities public CollectionFolder() { - PhysicalLocationsList = new List<string>(); - PhysicalFolderIds = new List<Guid>(); + PhysicalLocationsList = EmptyStringArray; + PhysicalFolderIds = EmptyGuidArray; } [IgnoreDataMember] @@ -140,7 +140,7 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public override IEnumerable<string> PhysicalLocations + public override string[] PhysicalLocations { get { @@ -153,12 +153,12 @@ namespace MediaBrowser.Controller.Entities return true; } - public List<string> PhysicalLocationsList { get; set; } - public List<Guid> PhysicalFolderIds { get; set; } + public string[] PhysicalLocationsList { get; set; } + public Guid[] PhysicalFolderIds { get; set; } protected override FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService) { - return CreateResolveArgs(directoryService, true).FileSystemChildren.ToArray(); + return CreateResolveArgs(directoryService, true).FileSystemChildren; } private bool _requiresRefresh; @@ -168,9 +168,9 @@ namespace MediaBrowser.Controller.Entities if (!changed) { - var locations = PhysicalLocations.ToList(); + var locations = PhysicalLocations; - var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations.ToList(); + var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations; if (!locations.SequenceEqual(newLocations)) { @@ -180,7 +180,7 @@ namespace MediaBrowser.Controller.Entities if (!changed) { - var folderIds = PhysicalFolderIds.ToList(); + var folderIds = PhysicalFolderIds; var newFolderIds = GetPhysicalFolders(false).Select(i => i.Id).ToList(); @@ -242,15 +242,15 @@ namespace MediaBrowser.Controller.Entities LinkedChildren = linkedChildren.ToArray(linkedChildren.Count); - var folderIds = PhysicalFolderIds.ToList(); - var newFolderIds = physicalFolders.Select(i => i.Id).ToList(); + var folderIds = PhysicalFolderIds; + var newFolderIds = physicalFolders.Select(i => i.Id).ToArray(); if (!folderIds.SequenceEqual(newFolderIds)) { changed = true; if (setFolders) { - PhysicalFolderIds = newFolderIds.ToList(); + PhysicalFolderIds = newFolderIds; } } @@ -307,7 +307,7 @@ namespace MediaBrowser.Controller.Entities _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); if (setPhysicalLocations) { - PhysicalLocationsList = args.PhysicalLocations.ToList(); + PhysicalLocationsList = args.PhysicalLocations; } return args; diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index eb2638ee4..a99058925 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -3,7 +3,6 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 836020d88..4e78a7fa5 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 4b70eae58..790f8938e 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Entities.Audio; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; using MediaBrowser.Model.Extensions; diff --git a/MediaBrowser.Controller/Entities/ICollectionFolder.cs b/MediaBrowser.Controller/Entities/ICollectionFolder.cs index d8b02034c..b70ad322d 100644 --- a/MediaBrowser.Controller/Entities/ICollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/ICollectionFolder.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Entities string Path { get; } string Name { get; } Guid Id { get; } - IEnumerable<string> PhysicalLocations { get; } + string[] PhysicalLocations { get; } } public interface ISupportsUserSpecificView diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs index 05d23d986..9e0e9c208 100644 --- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities public class InternalPeopleQuery { public Guid ItemId { get; set; } - public List<string> PersonTypes { get; set; } + public string[] PersonTypes { get; set; } public List<string> ExcludePersonTypes { get; set; } public int? MaxListOrder { get; set; } public Guid AppearsInItemId { get; set; } @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities public InternalPeopleQuery() { - PersonTypes = new List<string>(); + PersonTypes = new string[] {}; ExcludePersonTypes = new List<string>(); } } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 2768d8465..900e8a664 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Controller.Providers; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; @@ -169,7 +168,7 @@ namespace MediaBrowser.Controller.Entities.Movies if (base.IsVisible(user)) { - return base.GetChildren(user, true).Any(); + return base.GetChildren(user, true).Count > 0; } return false; diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 2028c1c3b..b7470d679 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -9,15 +9,15 @@ namespace MediaBrowser.Controller.Entities public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasLookupInfo<MusicVideoInfo> { [IgnoreDataMember] - public List<string> Artists { get; set; } + public string[] Artists { get; set; } public MusicVideo() { - Artists = new List<string>(); + Artists = EmptyStringArray; } [IgnoreDataMember] - public List<string> AllArtists + public string[] AllArtists { get { diff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.cs index 40a93d9e6..412eb9499 100644 --- a/MediaBrowser.Controller/Entities/PeopleHelper.cs +++ b/MediaBrowser.Controller/Entities/PeopleHelper.cs @@ -105,7 +105,15 @@ namespace MediaBrowser.Controller.Entities { throw new ArgumentNullException("name"); } - return people.Any(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)); + + foreach (var i in people) + { + if (string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + return false; } } } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 20d9c7999..b3a91f944 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Providers; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; using MediaBrowser.Model.Entities; diff --git a/MediaBrowser.Controller/Entities/Photo.cs b/MediaBrowser.Controller/Entities/Photo.cs index e95ceee52..8e9eac50c 100644 --- a/MediaBrowser.Controller/Entities/Photo.cs +++ b/MediaBrowser.Controller/Entities/Photo.cs @@ -1,5 +1,4 @@ using MediaBrowser.Model.Drawing; -using System.Linq; using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities @@ -39,7 +38,16 @@ namespace MediaBrowser.Controller.Entities { get { - return GetParents().OfType<PhotoAlbum>().FirstOrDefault(); + var parents = GetParents(); + foreach (var parent in parents) + { + var photoAlbum = parent as PhotoAlbum; + if (photoAlbum != null) + { + return photoAlbum; + } + } + return null; } } diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 8cb65c60a..a6a72d994 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 8b934bc47..bf6dc5678 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Entities.TV public override int GetChildCount(User user) { - var result = GetChildren(user, true).Count(); + var result = GetChildren(user, true).Count; return result; } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 545e8518a..6514d31d2 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -214,7 +214,15 @@ namespace MediaBrowser.Controller.Entities.TV { get { - return Children.OfType<Video>().Any(); + var children = Children; + foreach (var child in children) + { + if (child is Video) + { + return true; + } + } + return false; } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index d5d229bb3..851686ea8 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -5,7 +5,6 @@ using MediaBrowser.Model.Connect; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Users; using System; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -279,7 +278,14 @@ namespace MediaBrowser.Controller.Entities return true; } - return schedules.Any(i => IsParentalScheduleAllowed(i, date)); + foreach (var i in schedules) + { + if (IsParentalScheduleAllowed(i, date)) + { + return true; + } + } + return false; } private bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date) @@ -304,7 +310,14 @@ namespace MediaBrowser.Controller.Entities public bool IsFolderGrouped(Guid id) { - return Configuration.GroupedFolders.Select(i => new Guid(i)).Contains(id); + foreach (var i in Configuration.GroupedFolders) + { + if (new Guid(i) == id) + { + return true; + } + } + return false; } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index dd70277a7..2ed3bf20f 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Entities { if (_childrenIds == null) { - var list = base.LoadChildren().ToList(); + var list = base.LoadChildren(); _childrenIds = list.Select(i => i.Id).ToList(); return list; } diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index 7ab4e98fc..66174034d 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -4,9 +4,9 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using System; using System.Collections.Generic; +using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; -using System.Linq; using MediaBrowser.Controller.Dto; namespace MediaBrowser.Controller.Entities @@ -60,7 +60,7 @@ namespace MediaBrowser.Controller.Entities public override int GetChildCount(User user) { - return GetChildren(user, true).Count(); + return GetChildren(user, true).Count; } protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index 61b1a3b1a..7d820b007 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 27af60700..880b3a0ce 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -3,7 +3,6 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.IO @@ -107,7 +106,15 @@ namespace MediaBrowser.Controller.IO } } - return dict.Values.ToArray(); + var returnResult = new FileSystemMetadata[dict.Count]; + var index = 0; + var values = dict.Values; + foreach (var value in values) + { + returnResult[index] = value; + index++; + } + return returnResult; } } diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 963e4b71b..56392eee7 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; - using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.IO; using MediaBrowser.Model.Configuration; @@ -134,7 +133,14 @@ namespace MediaBrowser.Controller.Library // Not officially supported but in some cases we can handle it. if (item == null) { - item = parent.GetParents().OfType<T>().FirstOrDefault(); + var parents = parent.GetParents(); + foreach (var currentParent in parents) + { + if (currentParent is T) + { + return true; + } + } } return item != null; @@ -167,12 +173,12 @@ namespace MediaBrowser.Controller.Library /// Gets the physical locations. /// </summary> /// <value>The physical locations.</value> - public IEnumerable<string> PhysicalLocations + public string[] PhysicalLocations { get { var paths = string.IsNullOrWhiteSpace(Path) ? new string[] { } : new[] { Path }; - return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations); + return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations).ToArray(); } } diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs index 693b7b221..bab334a6d 100644 --- a/MediaBrowser.Controller/Library/NameExtensions.cs +++ b/MediaBrowser.Controller/Library/NameExtensions.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.Linq; using MediaBrowser.Controller.Extensions; using MediaBrowser.Model.Extensions; @@ -9,25 +7,6 @@ namespace MediaBrowser.Controller.Library { public static class NameExtensions { - public static bool EqualsAny(IEnumerable<string> names, string x) - { - x = NormalizeForComparison(x); - - return names.Any(y => string.Compare(x, y, StringComparison.OrdinalIgnoreCase) == 0); - //return names.Any(y => string.Compare(x, y, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) == 0); - } - - private static string NormalizeForComparison(string name) - { - if (name == null) - { - return string.Empty; - } - - return name; - //return name.RemoveDiacritics(); - } - private static string RemoveDiacritics(string name) { if (name == null) @@ -44,27 +23,4 @@ namespace MediaBrowser.Controller.Library return names.DistinctBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase); } } - - public class DistinctNameComparer : IComparer<string>, IEqualityComparer<string> - { - public int Compare(string x, string y) - { - if (string.IsNullOrWhiteSpace(x) && string.IsNullOrWhiteSpace(y)) - { - return 0; - } - - return string.Compare(x.RemoveDiacritics(), y.RemoveDiacritics(), StringComparison.OrdinalIgnoreCase); - } - - public bool Equals(string x, string y) - { - return Compare(x, y) == 0; - } - - public int GetHashCode(string obj) - { - return (obj ?? string.Empty).GetHashCode(); - } - } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 25bc10dec..c29d73253 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -6,7 +6,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Library; diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 3efbc41f1..1607dbcba 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -9,7 +9,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.LiveTv { diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 2c26d3556..950949f37 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -5,7 +5,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Library; diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 337bb23a4..d957470d3 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -4,7 +4,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; - using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; @@ -73,14 +72,23 @@ namespace MediaBrowser.Controller.Providers return entries; } - public IEnumerable<FileSystemMetadata> GetFiles(string path) + public List<FileSystemMetadata> GetFiles(string path) { return GetFiles(path, false); } - public IEnumerable<FileSystemMetadata> GetFiles(string path, bool clearCache) + public List<FileSystemMetadata> GetFiles(string path, bool clearCache) { - return GetFileSystemEntries(path, clearCache).Where(i => !i.IsDirectory); + var list = new List<FileSystemMetadata>(); + var items = GetFileSystemEntries(path, clearCache); + foreach (var item in items) + { + if (!item.IsDirectory) + { + list.Add(item); + } + } + return list; } public FileSystemMetadata GetFile(string path) diff --git a/MediaBrowser.Controller/Providers/IDirectoryService.cs b/MediaBrowser.Controller/Providers/IDirectoryService.cs index 374703948..6f864f4be 100644 --- a/MediaBrowser.Controller/Providers/IDirectoryService.cs +++ b/MediaBrowser.Controller/Providers/IDirectoryService.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Providers public interface IDirectoryService { FileSystemMetadata[] GetFileSystemEntries(string path); - IEnumerable<FileSystemMetadata> GetFiles(string path); + List<FileSystemMetadata> GetFiles(string path); FileSystemMetadata GetFile(string path); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/MetadataResult.cs b/MediaBrowser.Controller/Providers/MetadataResult.cs index 99402a969..5ed55ea16 100644 --- a/MediaBrowser.Controller/Providers/MetadataResult.cs +++ b/MediaBrowser.Controller/Providers/MetadataResult.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using System; using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Controller.Providers { @@ -51,7 +50,15 @@ namespace MediaBrowser.Controller.Providers UserDataList = new List<UserItemData>(); } - var userData = UserDataList.FirstOrDefault(i => string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)); + UserItemData userData = null; + + foreach (var i in UserDataList) + { + if (string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)) + { + userData = i; + } + } if (userData == null) { diff --git a/MediaBrowser.Controller/Providers/SongInfo.cs b/MediaBrowser.Controller/Providers/SongInfo.cs index 988e931cd..e3a6f5d37 100644 --- a/MediaBrowser.Controller/Providers/SongInfo.cs +++ b/MediaBrowser.Controller/Providers/SongInfo.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; namespace MediaBrowser.Controller.Providers { @@ -6,11 +5,11 @@ namespace MediaBrowser.Controller.Providers { public string[] AlbumArtists { get; set; } public string Album { get; set; } - public List<string> Artists { get; set; } + public string[] Artists { get; set; } public SongInfo() { - Artists = new List<string>(); + Artists = EmptyStringArray; AlbumArtists = EmptyStringArray; } } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 265f4f544..90c1de2f2 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Session; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Threading; @@ -194,7 +193,19 @@ namespace MediaBrowser.Controller.Session public bool ContainsUser(Guid userId) { - return (UserId ?? Guid.Empty) == userId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); + if ((UserId ?? Guid.Empty) == userId) + { + return true; + } + + foreach (var additionalUser in AdditionalUsers) + { + if (userId == new Guid(additionalUser.UserId)) + { + return true; + } + } + return false; } private readonly object _progressLock = new object(); |
