diff --git a/Emby.Dlna/ContentDirectory/ContentDirectory.cs b/Emby.Dlna/ContentDirectory/ContentDirectory.cs index 92d388e3b2..d547ad8d43 100644 --- a/Emby.Dlna/ContentDirectory/ContentDirectory.cs +++ b/Emby.Dlna/ContentDirectory/ContentDirectory.cs @@ -10,7 +10,6 @@ using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.TV; using MediaBrowser.Model.Globalization; @@ -129,9 +128,20 @@ namespace Emby.Dlna.ContentDirectory } } - // No configuration so it's going to be pretty arbitrary - return _userManager.Users.FirstOrDefault(i => i.Policy.IsAdministrator) ?? - _userManager.Users.First(); + foreach (var user in _userManager.Users) + { + if (user.Policy.IsAdministrator) + { + return user; + } + } + + foreach (var user in _userManager.Users) + { + return user; + } + + return null; } public void Dispose() diff --git a/Emby.Dlna/Didl/Filter.cs b/Emby.Dlna/Didl/Filter.cs index 5e9aeb530a..2c9a1ea184 100644 --- a/Emby.Dlna/Didl/Filter.cs +++ b/Emby.Dlna/Didl/Filter.cs @@ -1,13 +1,12 @@ using MediaBrowser.Model.Extensions; using System; using System.Collections.Generic; -using System.Linq; namespace Emby.Dlna.Didl { public class Filter { - private readonly List _fields; + private readonly string[] _fields; private readonly bool _all; public Filter() @@ -20,9 +19,7 @@ namespace Emby.Dlna.Didl { _all = StringHelper.EqualsIgnoreCase(filter, "*"); - var list = (filter ?? string.Empty).Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList(); - - _fields = list; + _fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } public bool Contains(string field) diff --git a/Emby.Dlna/Didl/StringWriterWithEncoding.cs b/Emby.Dlna/Didl/StringWriterWithEncoding.cs index 052d6610b1..b5c565801f 100644 --- a/Emby.Dlna/Didl/StringWriterWithEncoding.cs +++ b/Emby.Dlna/Didl/StringWriterWithEncoding.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index d563b5addd..4b77f998d3 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -13,7 +13,6 @@ using MediaBrowser.Model.System; using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Configuration; @@ -49,7 +48,7 @@ namespace Emby.Dlna.PlayTo { get { - var lastDateKnownActivity = new[] { _creationTime, _device.DateLastActivity }.Max(); + var lastDateKnownActivity = _creationTime > _device.DateLastActivity ? _creationTime : _device.DateLastActivity; if (DateTime.UtcNow >= lastDateKnownActivity.AddSeconds(120)) { @@ -565,7 +564,7 @@ namespace Emby.Dlna.PlayTo streamInfo.TargetVideoCodecTag, streamInfo.IsTargetAVC); - return list.FirstOrDefault(); + return list.Count == 0 ? null : list[0]; } return null; diff --git a/Emby.Dlna/Profiles/PanasonicVieraProfile.cs b/Emby.Dlna/Profiles/PanasonicVieraProfile.cs index 63c7e3a8e0..095788485b 100644 --- a/Emby.Dlna/Profiles/PanasonicVieraProfile.cs +++ b/Emby.Dlna/Profiles/PanasonicVieraProfile.cs @@ -30,107 +30,6 @@ namespace Emby.Dlna.Profiles TimelineOffsetSeconds = 10; - TranscodingProfiles = new[] - { - new TranscodingProfile - { - Container = "mp3", - AudioCodec = "mp3", - Type = DlnaProfileType.Audio - }, - new TranscodingProfile - { - Container = "ts", - AudioCodec = "ac3", - VideoCodec = "h264", - Type = DlnaProfileType.Video - }, - new TranscodingProfile - { - Container = "jpeg", - Type = DlnaProfileType.Photo - } - }; - - DirectPlayProfiles = new[] - { - new DirectPlayProfile - { - Container = "mpeg,mpg", - VideoCodec = "mpeg2video,mpeg4", - AudioCodec = "ac3,mp3,pcm_dvd", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mkv", - VideoCodec = "h264,mpeg2video", - AudioCodec = "aac,ac3,dca,mp3,mp2,pcm,dts", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "ts", - VideoCodec = "h264,mpeg2video", - AudioCodec = "aac,mp3,mp2", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mp4,m4v", - VideoCodec = "h264", - AudioCodec = "aac,ac3,mp3,pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mov", - VideoCodec = "h264", - AudioCodec = "aac,pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "avi", - VideoCodec = "mpeg4", - AudioCodec = "pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "flv", - VideoCodec = "h264", - AudioCodec = "aac", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mp3", - AudioCodec = "mp3", - Type = DlnaProfileType.Audio - }, - - new DirectPlayProfile - { - Container = "mp4", - AudioCodec = "aac", - Type = DlnaProfileType.Audio - }, - - new DirectPlayProfile - { - Container = "jpeg", - Type = DlnaProfileType.Photo - } - }; - ContainerProfiles = new[] { new ContainerProfile diff --git a/Emby.Dlna/Ssdp/Extensions.cs b/Emby.Dlna/Ssdp/Extensions.cs index 611bf7e022..41a361515b 100644 --- a/Emby.Dlna/Ssdp/Extensions.cs +++ b/Emby.Dlna/Ssdp/Extensions.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Net; using System.Threading.Tasks; using System.Xml.Linq; @@ -24,10 +23,12 @@ namespace Emby.Dlna.Ssdp public static string GetDescendantValue(this XElement container, XName name) { - var node = container.Descendants(name) - .FirstOrDefault(); + foreach (var node in container.Descendants(name)) + { + return node.Value; + } - return node == null ? null : node.Value; + return null; } } } diff --git a/Emby.Drawing.ImageMagick/ImageHelpers.cs b/Emby.Drawing.ImageMagick/ImageHelpers.cs index c623c21aa2..8666933995 100644 --- a/Emby.Drawing.ImageMagick/ImageHelpers.cs +++ b/Emby.Drawing.ImageMagick/ImageHelpers.cs @@ -6,13 +6,13 @@ namespace Emby.Drawing.ImageMagick { internal static class ImageHelpers { - internal static List ProjectPaths(List paths, int count) + internal static List ProjectPaths(string[] paths, int count) { if (count <= 0) { throw new ArgumentOutOfRangeException("count"); } - if (paths.Count == 0) + if (paths.Length == 0) { throw new ArgumentOutOfRangeException("paths"); } @@ -24,7 +24,7 @@ namespace Emby.Drawing.ImageMagick return list.Take(count).ToList(); } - private static void AddToList(List list, List paths, int count) + private static void AddToList(List list, string[] paths, int count) { while (list.Count < count) { diff --git a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs index ea8687de01..9abf85e70f 100644 --- a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs +++ b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs @@ -7,7 +7,6 @@ using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Logging; using System; using System.IO; -using System.Linq; using MediaBrowser.Model.IO; using MediaBrowser.Model.System; @@ -306,15 +305,15 @@ namespace Emby.Drawing.ImageMagick if (ratio >= 1.4) { - new StripCollageBuilder(_appPaths, _fileSystem).BuildThumbCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildThumbCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } else if (ratio >= .9) { - new StripCollageBuilder(_appPaths, _fileSystem).BuildSquareCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildSquareCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } else { - new StripCollageBuilder(_appPaths, _fileSystem).BuildPosterCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildPosterCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } } diff --git a/Emby.Drawing.ImageMagick/StripCollageBuilder.cs b/Emby.Drawing.ImageMagick/StripCollageBuilder.cs index 63cf8fe5f9..26c6c868db 100644 --- a/Emby.Drawing.ImageMagick/StripCollageBuilder.cs +++ b/Emby.Drawing.ImageMagick/StripCollageBuilder.cs @@ -19,7 +19,7 @@ namespace Emby.Drawing.ImageMagick _fileSystem = fileSystem; } - public void BuildPosterCollage(List paths, string outputPath, int width, int height) + public void BuildPosterCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildPosterCollageWand(paths, width, height)) { @@ -27,7 +27,7 @@ namespace Emby.Drawing.ImageMagick } } - public void BuildSquareCollage(List paths, string outputPath, int width, int height) + public void BuildSquareCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildSquareCollageWand(paths, width, height)) { @@ -35,7 +35,7 @@ namespace Emby.Drawing.ImageMagick } } - public void BuildThumbCollage(List paths, string outputPath, int width, int height) + public void BuildThumbCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildThumbCollageWand(paths, width, height)) { @@ -43,7 +43,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildPosterCollageWand(List paths, int width, int height) + private MagickWand BuildPosterCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 3); using (var wandImages = new MagickWand(inputPaths.ToArray())) @@ -108,7 +108,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildThumbCollageWand(List paths, int width, int height) + private MagickWand BuildThumbCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 4); using (var wandImages = new MagickWand(inputPaths.ToArray())) @@ -173,7 +173,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildSquareCollageWand(List paths, int width, int height) + private MagickWand BuildSquareCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 4); var outputWand = new MagickWand(width, height, new PixelWand("none", 1)); diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index bd23eba7aa..63fa5f1f5e 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -44,7 +44,7 @@ namespace Emby.Drawing /// Image processors are specialized metadata providers that run after the normal ones /// /// The image enhancers. - public IEnumerable ImageEnhancers { get; private set; } + public IImageEnhancer[] ImageEnhancers { get; private set; } /// /// The _logger @@ -71,7 +71,7 @@ namespace Emby.Drawing _libraryManager = libraryManager; _appPaths = appPaths; - ImageEnhancers = new List(); + ImageEnhancers = new IImageEnhancer[] {}; _saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite); ImageHelper.ImageProcessor = this; @@ -618,7 +618,7 @@ namespace Emby.Drawing var supportedEnhancers = GetSupportedEnhancers(item, image.Type); - return GetImageCacheTag(item, image, supportedEnhancers.ToList()); + return GetImageCacheTag(item, image, supportedEnhancers); } /// @@ -672,7 +672,7 @@ namespace Emby.Drawing /// Task{System.String}. public async Task GetEnhancedImage(IHasMetadata item, ImageType imageType, int imageIndex) { - var enhancers = GetSupportedEnhancers(item, imageType).ToList(); + var enhancers = GetSupportedEnhancers(item, imageType); var imageInfo = item.GetImageInfo(imageType, imageIndex); @@ -866,21 +866,25 @@ namespace Emby.Drawing _logger.Info("Completed creation of image collage and saved to {0}", options.OutputPath); } - public IEnumerable GetSupportedEnhancers(IHasMetadata item, ImageType imageType) + public List GetSupportedEnhancers(IHasMetadata item, ImageType imageType) { - return ImageEnhancers.Where(i => + var list = new List(); + + foreach (var i in ImageEnhancers) { try { - return i.Supports(item, imageType); + if (i.Supports(item, imageType)) + { + list.Add(i); + } } catch (Exception ex) { _logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); - - return false; } - }); + } + return list; } private bool _disposed; diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index ea6c2aaf5f..6441fe4f2d 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -861,7 +861,7 @@ namespace Emby.Server.Implementations SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager, FileSystemManager, CryptographyProvider); RegisterSingleInstance(SecurityManager); - InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager, CryptographyProvider); + InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager, CryptographyProvider, PackageRuntime); RegisterSingleInstance(InstallationManager); ZipClient = new ZipClient(FileSystemManager); @@ -1048,6 +1048,14 @@ namespace Emby.Server.Implementations await ((UserManager)UserManager).Initialize().ConfigureAwait(false); } + protected virtual string PackageRuntime + { + get + { + return "netframework"; + } + } + public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, bool isStartup) { logger.LogMultiline("Emby", LogSeverity.Info, GetBaseExceptionMessage(appPaths)); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 28a1503700..d8d69a62ed 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -1330,7 +1330,7 @@ namespace Emby.Server.Implementations.Channels var hasArtists = item as IHasArtist; if (hasArtists != null) { - hasArtists.Artists = info.Artists; + hasArtists.Artists = info.Artists.ToArray(); } var hasAlbumArtists = item as IHasAlbumArtist; diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 064a66cd0a..423ad2782b 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -1028,9 +1028,9 @@ namespace Emby.Server.Implementations.Data var hasArtists = item as IHasArtist; if (hasArtists != null) { - if (hasArtists.Artists.Count > 0) + if (hasArtists.Artists.Length > 0) { - artists = string.Join("|", hasArtists.Artists.ToArray()); + artists = string.Join("|", hasArtists.Artists); } } saveItemStatement.TryBind("@Artists", artists); @@ -1908,7 +1908,7 @@ namespace Emby.Server.Implementations.Data var hasArtists = item as IHasArtist; if (hasArtists != null && !reader.IsDBNull(index)) { - hasArtists.Artists = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); + hasArtists.Artists = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } index++; diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 17e91bfa88..0282572708 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1617,7 +1617,7 @@ namespace Emby.Server.Implementations.Dto return null; } - var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList(); + var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary); ImageSize size; diff --git a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs index 6c7c1f052f..6a1f8ec6f2 100644 --- a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Library.Resolvers return new CollectionFolder { CollectionType = GetCollectionType(args), - PhysicalLocationsList = args.PhysicalLocations.ToList() + PhysicalLocationsList = args.PhysicalLocations }; } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index f3d40ae19e..2e12f46bf9 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -607,20 +607,22 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var timer = _timerProvider.GetTimer(timerId); if (timer != null) { + timer.Status = RecordingStatus.Cancelled; + if (string.IsNullOrWhiteSpace(timer.SeriesTimerId) || isSeriesCancelled) { _timerProvider.Delete(timer); } else { - timer.Status = RecordingStatus.Cancelled; _timerProvider.AddOrUpdate(timer, false); } } ActiveRecordingInfo activeRecordingInfo; if (_activeRecordings.TryGetValue(timerId, out activeRecordingInfo)) - { + { + activeRecordingInfo.Timer = timer; activeRecordingInfo.CancellationTokenSource.Cancel(); } } @@ -865,7 +867,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public async Task> GetRecordingsAsync(CancellationToken cancellationToken) { return new List(); - //return _activeRecordings.Values.ToList().Select(GetRecordingInfo).ToList(); } public string GetActiveRecordingPath(string id) @@ -881,7 +882,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public IEnumerable GetAllActiveRecordings() { - return _activeRecordings.Values; + return _activeRecordings.Values.Where(i => i.Timer.Status == RecordingStatus.InProgress && !i.CancellationTokenSource.IsCancellationRequested); } public ActiveRecordingInfo GetActiveRecordingInfo(string path) @@ -893,59 +894,19 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV foreach (var recording in _activeRecordings.Values) { - if (string.Equals(recording.Path, path, StringComparison.Ordinal)) + if (string.Equals(recording.Path, path, StringComparison.Ordinal) && !recording.CancellationTokenSource.IsCancellationRequested) { + var timer = recording.Timer; + if (timer.Status != RecordingStatus.InProgress) + { + return null; + } return recording; } } return null; } - private RecordingInfo GetRecordingInfo(ActiveRecordingInfo info) - { - var timer = info.Timer; - var program = info.Program; - - var result = new RecordingInfo - { - ChannelId = timer.ChannelId, - CommunityRating = timer.CommunityRating, - DateLastUpdated = DateTime.UtcNow, - EndDate = timer.EndDate, - EpisodeTitle = timer.EpisodeTitle, - Genres = timer.Genres, - Id = "recording" + timer.Id, - IsKids = timer.IsKids, - IsMovie = timer.IsMovie, - IsNews = timer.IsNews, - IsRepeat = timer.IsRepeat, - IsSeries = timer.IsProgramSeries, - IsSports = timer.IsSports, - Name = timer.Name, - OfficialRating = timer.OfficialRating, - OriginalAirDate = timer.OriginalAirDate, - Overview = timer.Overview, - ProgramId = timer.ProgramId, - SeriesTimerId = timer.SeriesTimerId, - StartDate = timer.StartDate, - Status = RecordingStatus.InProgress, - TimerId = timer.Id - }; - - if (program != null) - { - result.Audio = program.Audio; - result.ImagePath = program.ImagePath; - result.ImageUrl = program.ImageUrl; - result.IsHD = program.IsHD; - result.IsLive = program.IsLive; - result.IsPremiere = program.IsPremiere; - result.ShowId = program.ShowId; - } - - return result; - } - public Task> GetTimersAsync(CancellationToken cancellationToken) { var excludeStatues = new List diff --git a/Emby.Server.Implementations/Notifications/Notifications.cs b/Emby.Server.Implementations/Notifications/Notifications.cs index f95b3f701a..ac3cc75647 100644 --- a/Emby.Server.Implementations/Notifications/Notifications.cs +++ b/Emby.Server.Implementations/Notifications/Notifications.cs @@ -422,7 +422,7 @@ namespace Emby.Server.Implementations.Notifications { var artists = hasArtist.AllArtists; - if (artists.Count > 0) + if (artists.Length > 0) { name = hasArtist.AllArtists[0] + " - " + name; } @@ -440,7 +440,7 @@ namespace Emby.Server.Implementations.Notifications name = item.SeriesName + " - " + name; } - if (item.Artists != null && item.Artists.Count > 0) + if (item.Artists != null && item.Artists.Length > 0) { name = item.Artists[0] + " - " + name; } diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index 526e62d398..f9fcfdbabd 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -215,13 +215,13 @@ namespace Emby.Server.Implementations.Services if (name == null) continue; //thank you ASP.NET var values = request.QueryString.GetValues(name); - if (values.Length == 1) + if (values.Count == 1) { map[name] = values[0]; } else { - for (var i = 0; i < values.Length; i++) + for (var i = 0; i < values.Count; i++) { map[name + (i == 0 ? "" : "#" + i)] = values[i]; } @@ -235,13 +235,13 @@ namespace Emby.Server.Implementations.Services if (name == null) continue; //thank you ASP.NET var values = request.FormData.GetValues(name); - if (values.Length == 1) + if (values.Count == 1) { map[name] = values[0]; } else { - for (var i = 0; i < values.Length; i++) + for (var i = 0; i < values.Count; i++) { map[name + (i == 0 ? "" : "#" + i)] = values[i]; } diff --git a/Emby.Server.Implementations/Sorting/ArtistComparer.cs b/Emby.Server.Implementations/Sorting/ArtistComparer.cs index edb195820f..616aff673d 100644 --- a/Emby.Server.Implementations/Sorting/ArtistComparer.cs +++ b/Emby.Server.Implementations/Sorting/ArtistComparer.cs @@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.Sorting return string.Empty; } - return audio.Artists.Count == 0 ? null : audio.Artists[0]; + return audio.Artists.Length == 0 ? null : audio.Artists[0]; } /// diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 393fb76e2f..75328a39a3 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -122,7 +122,10 @@ namespace Emby.Server.Implementations.Updates private readonly ICryptoProvider _cryptographyProvider; - public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config, IFileSystem fileSystem, ICryptoProvider cryptographyProvider) + // netframework or netcore + private readonly string _packageRuntime; + + public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config, IFileSystem fileSystem, ICryptoProvider cryptographyProvider, string packageRuntime) { if (logger == null) { @@ -140,6 +143,7 @@ namespace Emby.Server.Implementations.Updates _config = config; _fileSystem = fileSystem; _cryptographyProvider = cryptographyProvider; + _packageRuntime = packageRuntime; _logger = logger; } @@ -157,7 +161,7 @@ namespace Emby.Server.Implementations.Updates /// Gets all available packages. /// /// Task{List{PackageInfo}}. - public async Task GetAvailablePackages(CancellationToken cancellationToken, + public async Task> GetAvailablePackages(CancellationToken cancellationToken, bool withRegistration = true, string packageType = null, Version applicationVersion = null) @@ -171,7 +175,7 @@ namespace Emby.Server.Implementations.Updates { "systemid", _applicationHost.SystemId } }; - using (var json = await _httpClient.Post("https://www.mb3admin.com/admin/service/package/retrieveall", data, cancellationToken).ConfigureAwait(false)) + using (var json = await _httpClient.Post("https://www.mb3admin.com/admin/service/package/retrieveall?includeAllRuntimes=true", data, cancellationToken).ConfigureAwait(false)) { cancellationToken.ThrowIfCancellationRequested(); @@ -195,7 +199,7 @@ namespace Emby.Server.Implementations.Updates /// /// The cancellation token. /// Task{List{PackageInfo}}. - public async Task GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken) + public async Task> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken) { _logger.Info("Opening {0}", PackageCachePath); try @@ -209,7 +213,7 @@ namespace Emby.Server.Implementations.Updates UpdateCachedPackages(CancellationToken.None, false); } - return packages; + return FilterPackages(packages); } } catch (Exception) @@ -221,7 +225,7 @@ namespace Emby.Server.Implementations.Updates await UpdateCachedPackages(cancellationToken, true).ConfigureAwait(false); using (var stream = _fileSystem.OpenRead(PackageCachePath)) { - return _jsonSerializer.DeserializeFromStream(stream); + return FilterPackages(_jsonSerializer.DeserializeFromStream(stream)); } } @@ -244,7 +248,7 @@ namespace Emby.Server.Implementations.Updates var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions { - Url = "https://www.mb3admin.com/admin/service/MB3Packages.json", + Url = "https://www.mb3admin.com/admin/service/EmbyPackages.json", CancellationToken = cancellationToken, Progress = new SimpleProgress() @@ -280,47 +284,74 @@ namespace Emby.Server.Implementations.Updates return TimeSpan.FromMinutes(3); } - protected PackageInfo[] FilterPackages(List packages) + protected List FilterPackages(IEnumerable packages) { + var list = new List(); foreach (var package in packages) { - package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(GetPackageVersion).ToArray(); + var versions = new List(); + foreach (var version in package.versions) + { + if (string.IsNullOrWhiteSpace(version.sourceUrl)) + { + continue; + } + + if (string.IsNullOrWhiteSpace(version.runtimes) || version.runtimes.IndexOf(_packageRuntime, StringComparison.OrdinalIgnoreCase) == -1) + { + continue; + } + + versions.Add(version); + } + + package.versions = versions + .OrderByDescending(GetPackageVersion) + .ToArray(); + + if (package.versions.Length == 0) + { + continue; + } + + list.Add(package); } // Remove packages with no versions - return packages.Where(p => p.versions.Any()).ToArray(); + return list; } - protected PackageInfo[] FilterPackages(PackageInfo[] packages, string packageType, Version applicationVersion) + protected List FilterPackages(IEnumerable packages, string packageType, Version applicationVersion) { - foreach (var package in packages) - { - package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(GetPackageVersion).ToArray(); - } + var packagesList = FilterPackages(packages); - IEnumerable packagesList = packages; + var returnList = new List(); - if (!string.IsNullOrWhiteSpace(packageType)) - { - packagesList = packagesList.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)); - } + var filterOnPackageType = !string.IsNullOrWhiteSpace(packageType); - // If an app version was supplied, filter the versions for each package to only include supported versions - if (applicationVersion != null) + foreach (var p in packagesList) { - foreach (var package in packages) + if (filterOnPackageType && !string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)) { - package.versions = package.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToArray(); + continue; } - } - // Remove packages with no versions - packagesList = packagesList.Where(p => p.versions.Any()); + // If an app version was supplied, filter the versions for each package to only include supported versions + if (applicationVersion != null) + { + p.versions = p.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToArray(); + } + + if (p.versions.Length == 0) + { + continue; + } + + returnList.Add(p); + } - return packagesList.ToArray(); + return returnList; } /// diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index c7ceb41bcb..35ac2b4828 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -231,7 +231,7 @@ namespace MediaBrowser.Api SortOrder = request.SortOrder, SortBy = (request.SortBy ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), Filters = request.GetFilters().ToArray(), - Fields = request.GetItemFields().ToArray() + Fields = request.GetItemFields() }, CancellationToken.None).ConfigureAwait(false); diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs index 92128634e3..643ecd9c86 100644 --- a/MediaBrowser.Api/ConfigurationService.cs +++ b/MediaBrowser.Api/ConfigurationService.cs @@ -6,7 +6,6 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Serialization; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Controller.IO; diff --git a/MediaBrowser.Api/Devices/DeviceService.cs b/MediaBrowser.Api/Devices/DeviceService.cs index 544960f5f5..012f0ddb27 100644 --- a/MediaBrowser.Api/Devices/DeviceService.cs +++ b/MediaBrowser.Api/Devices/DeviceService.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Devices; @@ -143,7 +142,7 @@ namespace MediaBrowser.Api.Devices } else { - var file = Request.Files.First(); + var file = Request.Files.Length == 0 ? null : Request.Files[0]; var task = _deviceManager.AcceptCameraUpload(deviceId, file.InputStream, new LocalFileInfo { diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs index fc8c0edf6b..389244aa96 100644 --- a/MediaBrowser.Api/Dlna/DlnaServerService.cs +++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Controller.IO; diff --git a/MediaBrowser.Api/Dlna/DlnaService.cs b/MediaBrowser.Api/Dlna/DlnaService.cs index fa3287ebdd..4dd71f4463 100644 --- a/MediaBrowser.Api/Dlna/DlnaService.cs +++ b/MediaBrowser.Api/Dlna/DlnaService.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Dlna; +using System.Linq; +using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Dlna; -using System.Linq; using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Dlna diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 318360336a..309c7195ba 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -556,20 +556,7 @@ namespace MediaBrowser.Api.Images throw new ResourceNotFoundException(string.Format("{0} does not have an image of type {1}", item.Name, request.Type)); } - var supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.ImageEnhancers.Where(i => - { - try - { - return i.Supports(item, request.Type); - } - catch (Exception ex) - { - Logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); - - return false; - } - - }).ToList() : new List(); + var supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.GetSupportedEnhancers(item, request.Type) : new List(); var cropwhitespace = request.Type == ImageType.Logo || request.Type == ImageType.Art diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 56caf884bb..47bd46ea5d 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -352,7 +352,7 @@ namespace MediaBrowser.Api hasArtists.Artists = request .ArtistItems .Select(i => i.Name) - .ToList(); + .ToArray(); } } diff --git a/MediaBrowser.Api/LocalizationService.cs b/MediaBrowser.Api/LocalizationService.cs index 2c92505b17..56d32fc374 100644 --- a/MediaBrowser.Api/LocalizationService.cs +++ b/MediaBrowser.Api/LocalizationService.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Services; namespace MediaBrowser.Api diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs index 6511d31279..c63712f4cc 100644 --- a/MediaBrowser.Api/Movies/CollectionService.cs +++ b/MediaBrowser.Api/Movies/CollectionService.cs @@ -4,7 +4,6 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Model.Collections; using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index 7873c1cd38..3e42026b14 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -426,7 +426,7 @@ namespace MediaBrowser.Api.Movies { var people = _libraryManager.GetPeople(new InternalPeopleQuery { - PersonTypes = new List + PersonTypes = new string[] { PersonType.Director } diff --git a/MediaBrowser.Api/PlaylistService.cs b/MediaBrowser.Api/PlaylistService.cs index 07a976f396..54c995d3d1 100644 --- a/MediaBrowser.Api/PlaylistService.cs +++ b/MediaBrowser.Api/PlaylistService.cs @@ -1,11 +1,11 @@ -using MediaBrowser.Controller.Dto; +using System.Linq; +using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Playlists; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Playlists; using MediaBrowser.Model.Querying; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; using MediaBrowser.Model.Extensions; diff --git a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs index 6b10fcb05d..6a1502c7e6 100644 --- a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs +++ b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs @@ -533,7 +533,7 @@ namespace MediaBrowser.Api.Reports break; case HeaderMetadata.Tracks: - option.Column = (i, r) => this.GetObject>(i, (x) => x.Tracks.ToList(), new List /// The physical locations. - public IEnumerable 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 693b7b2217..bab334a6d2 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 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, IEqualityComparer - { - 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 25bc10dec0..c29d732532 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 3efbc41f1d..1607dbcba1 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 2c26d35560..950949f37a 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 337bb23a48..d957470d3b 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 GetFiles(string path) + public List GetFiles(string path) { return GetFiles(path, false); } - public IEnumerable GetFiles(string path, bool clearCache) + public List GetFiles(string path, bool clearCache) { - return GetFileSystemEntries(path, clearCache).Where(i => !i.IsDirectory); + var list = new List(); + 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 3747039482..6f864f4be2 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 GetFiles(string path); + List 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 99402a9694..5ed55ea162 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(); } - 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 988e931cd3..e3a6f5d37e 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 Artists { get; set; } + public string[] Artists { get; set; } public SongInfo() { - Artists = new List(); + Artists = EmptyStringArray; AlbumArtists = EmptyStringArray; } } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 265f4f544e..90c1de2f2b 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(); diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index 881d2a85a8..9195a9cd41 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -4,10 +4,8 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; namespace MediaBrowser.LocalMetadata.Images @@ -40,49 +38,50 @@ namespace MediaBrowser.LocalMetadata.Images { var parentPath = _fileSystem.GetDirectoryName(item.Path); - var parentPathFiles = directoryService.GetFiles(parentPath) - .ToList(); + var parentPathFiles = directoryService.GetFiles(parentPath); var nameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(item.Path); return GetFilesFromParentFolder(nameWithoutExtension, parentPathFiles); } - private List GetFilesFromParentFolder(string filenameWithoutExtension, IEnumerable parentPathFiles) + private List GetFilesFromParentFolder(string filenameWithoutExtension, List parentPathFiles) { var thumbName = filenameWithoutExtension + "-thumb"; - return parentPathFiles - .Where(i => - { - if (i.IsDirectory) - { - return false; - } - - if (BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) - { - var currentNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(i); - - if (string.Equals(filenameWithoutExtension, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - if (string.Equals(thumbName, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - } - - return false; - }) - .Select(i => new LocalImageInfo - { - FileInfo = i, - Type = ImageType.Primary - }) - .ToList(); + var list = new List(1); + + foreach (var i in parentPathFiles) + { + if (i.IsDirectory) + { + continue; + } + + if (BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) + { + var currentNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(i); + + if (string.Equals(filenameWithoutExtension, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) + { + list.Add(new LocalImageInfo + { + FileInfo = i, + Type = ImageType.Primary + }); + } + + else if (string.Equals(thumbName, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) + { + list.Add(new LocalImageInfo + { + FileInfo = i, + Type = ImageType.Primary + }); + } + } + } + return list; } } } diff --git a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs index ddfb703212..56a2c271f9 100644 --- a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; - using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 8da20c9f5b..8bad650b53 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -432,7 +432,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the artists. /// /// The artists. - public List Artists { get; set; } + public string[] Artists { get; set; } /// /// Gets or sets the artist items. diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 8f3f0648d3..27920bdf39 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Extensions; using MediaBrowser.Model.MediaInfo; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Session; @@ -91,19 +90,15 @@ namespace MediaBrowser.Model.Dto return; } - var internalStreams = MediaStreams - .Where(i => !i.IsExternal) - .ToList(); - - if (internalStreams.Count == 0) + var bitrate = 0; + foreach (var stream in MediaStreams) { - return; + if (!stream.IsExternal) + { + bitrate += stream.BitRate ?? 0; + } } - var bitrate = internalStreams - .Select(m => m.BitRate ?? 0) - .Sum(); - if (bitrate > 0) { Bitrate = bitrate; diff --git a/MediaBrowser.Model/Extensions/ListHelper.cs b/MediaBrowser.Model/Extensions/ListHelper.cs index cfcb229c8f..6fe1793dba 100644 --- a/MediaBrowser.Model/Extensions/ListHelper.cs +++ b/MediaBrowser.Model/Extensions/ListHelper.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Model.Extensions { @@ -13,7 +11,14 @@ namespace MediaBrowser.Model.Extensions throw new ArgumentNullException("value"); } - return list.Contains(value, StringComparer.OrdinalIgnoreCase); + foreach (var item in list) + { + if (string.Equals(item, value, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + return false; } public static bool ContainsAnyIgnoreCase(string[] list, string[] values) diff --git a/MediaBrowser.Model/Services/QueryParamCollection.cs b/MediaBrowser.Model/Services/QueryParamCollection.cs index a3e00f587c..e13e5fecac 100644 --- a/MediaBrowser.Model/Services/QueryParamCollection.cs +++ b/MediaBrowser.Model/Services/QueryParamCollection.cs @@ -58,9 +58,7 @@ namespace MediaBrowser.Model.Services { if (string.IsNullOrWhiteSpace(value)) { - var stringComparison = GetStringComparison(); - - var parameters = this.Where(p => string.Equals(key, p.Name, stringComparison)).ToArray(); + var parameters = GetItems(key); foreach (var p in parameters) { @@ -84,14 +82,6 @@ namespace MediaBrowser.Model.Services Add(key, value); } - /// - /// True if the collection contains a query parameter with the given name. - /// - public bool ContainsKey(string name) - { - return this.Any(p => p.Name == name); - } - /// /// Removes all parameters of the given name. /// @@ -106,16 +96,49 @@ namespace MediaBrowser.Model.Services { var stringComparison = GetStringComparison(); - return this.Where(p => string.Equals(p.Name, name, stringComparison)) - .Select(p => p.Value) - .FirstOrDefault(); + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + return pair.Value; + } + } + + return null; + } + + public virtual List GetItems(string name) + { + var stringComparison = GetStringComparison(); + + var list = new List(); + + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + list.Add(pair); + } + } + + return list; } - public virtual string[] GetValues(string name) + public virtual List GetValues(string name) { var stringComparison = GetStringComparison(); - return this.Where(p => string.Equals(p.Name, name, stringComparison)).Select(p => p.Value).ToArray(); + var list = new List(); + + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + list.Add(pair.Value); + } + } + + return list; } public Dictionary ToDictionary() @@ -134,7 +157,17 @@ namespace MediaBrowser.Model.Services public IEnumerable Keys { - get { return this.Select(i => i.Name); } + get + { + var keys = new string[this.Count]; + + for (var i = 0; i < keys.Length; i++) + { + keys[i] = this[i].Name; + } + + return keys; + } } /// diff --git a/MediaBrowser.Model/Updates/PackageVersionInfo.cs b/MediaBrowser.Model/Updates/PackageVersionInfo.cs index 5e0631b3b7..3ac5181872 100644 --- a/MediaBrowser.Model/Updates/PackageVersionInfo.cs +++ b/MediaBrowser.Model/Updates/PackageVersionInfo.cs @@ -89,5 +89,7 @@ namespace MediaBrowser.Model.Updates public string targetFilename { get; set; } public string infoUrl { get; set; } + + public string runtimes { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Providers/Books/AudioBookMetadataService.cs b/MediaBrowser.Providers/Books/AudioBookMetadataService.cs index b9e265d22e..834ec6cd39 100644 --- a/MediaBrowser.Providers/Books/AudioBookMetadataService.cs +++ b/MediaBrowser.Providers/Books/AudioBookMetadataService.cs @@ -23,9 +23,9 @@ namespace MediaBrowser.Providers.Books var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs b/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs index 2ea0a7ee96..09546e4b61 100644 --- a/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs +++ b/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs @@ -23,9 +23,9 @@ namespace MediaBrowser.Providers.Books var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index 81cd416050..12748a8a77 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -41,11 +41,7 @@ namespace MediaBrowser.Providers.BoxSets if (mergeMetadataSettings) { - // Retain shortcut children - var linkedChildren = sourceItem.LinkedChildren.ToList(); - linkedChildren.AddRange(sourceItem.LinkedChildren.Where(i => i.Type == LinkedChildType.Shortcut)); - - targetItem.LinkedChildren = linkedChildren.ToArray(linkedChildren.Count); + targetItem.LinkedChildren = sourceItem.LinkedChildren; targetItem.Shares = sourceItem.Shares; } } diff --git a/MediaBrowser.Providers/Chapters/ChapterManager.cs b/MediaBrowser.Providers/Chapters/ChapterManager.cs index 3973d3de7b..d3e9efd820 100644 --- a/MediaBrowser.Providers/Chapters/ChapterManager.cs +++ b/MediaBrowser.Providers/Chapters/ChapterManager.cs @@ -13,7 +13,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs b/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs index 03bb0f68c9..e245476146 100644 --- a/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs b/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs index e6e93e4433..ec908095f9 100644 --- a/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs +++ b/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs b/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs index 8da88e1c6f..a49d42acaa 100644 --- a/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/IPriorityQueue.cs b/MediaBrowser.Providers/Manager/IPriorityQueue.cs index 425992b18b..23f08a13e2 100644 --- a/MediaBrowser.Providers/Manager/IPriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/IPriorityQueue.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs index f4c261a810..879ae1dca4 100644 --- a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index b8b6032452..a4f2053a9d 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Providers.MediaInfo private string GetAudioImagePath(Audio item) { var filename = item.Album ?? string.Empty; - filename += string.Join(",", item.Artists.ToArray(item.Artists.Count)); + filename += string.Join(",", item.Artists); if (!string.IsNullOrWhiteSpace(item.Album)) { diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs index fb1fed8b3f..b0785298b8 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs @@ -141,7 +141,7 @@ namespace MediaBrowser.Providers.MediaInfo } audio.Album = data.Album; - audio.Artists = data.Artists.ToList(); + audio.Artists = data.Artists; audio.AlbumArtists = data.AlbumArtists; audio.IndexNumber = data.IndexNumber; audio.ParentIndexNumber = data.ParentIndexNumber; diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.cs index fe39a841e4..4230c517ae 100644 --- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs +++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs @@ -106,7 +106,7 @@ namespace MediaBrowser.Providers.Music .SelectMany(i => i.Artists) .Distinct(StringComparer.OrdinalIgnoreCase) .OrderBy(i => i) - .ToList(); + .ToArray(); if (!item.Artists.SequenceEqual(artists, StringComparer.OrdinalIgnoreCase)) { @@ -158,7 +158,7 @@ namespace MediaBrowser.Providers.Music var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { targetItem.Artists = sourceItem.Artists; } diff --git a/MediaBrowser.Providers/Music/ArtistMetadataService.cs b/MediaBrowser.Providers/Music/ArtistMetadataService.cs index c8008ba1ec..0ff161576f 100644 --- a/MediaBrowser.Providers/Music/ArtistMetadataService.cs +++ b/MediaBrowser.Providers/Music/ArtistMetadataService.cs @@ -31,7 +31,7 @@ namespace MediaBrowser.Providers.Music }) : item.GetRecursiveChildren(i => i is IHasArtist && !i.IsFolder); - var currentList = item.Genres.ToList(); + var currentList = item.Genres; item.Genres = taggedItems.SelectMany(i => i.Genres) .DistinctNames() diff --git a/MediaBrowser.Providers/Music/AudioMetadataService.cs b/MediaBrowser.Providers/Music/AudioMetadataService.cs index 68a4fcd7cb..f02eae19fc 100644 --- a/MediaBrowser.Providers/Music/AudioMetadataService.cs +++ b/MediaBrowser.Providers/Music/AudioMetadataService.cs @@ -21,9 +21,9 @@ namespace MediaBrowser.Providers.Music var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs b/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs index 27c6deb740..28504dbd74 100644 --- a/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs +++ b/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs @@ -28,9 +28,9 @@ namespace MediaBrowser.Providers.Music targetItem.Album = sourceItem.Album; } - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } } diff --git a/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs b/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs index dccef3a09a..d39d3baf5d 100644 --- a/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs +++ b/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs @@ -42,12 +42,9 @@ namespace MediaBrowser.Providers.Playlists { if (!item.IsLocked && !item.LockedFields.Contains(MetadataFields.Genres)) { - var items = item.GetLinkedChildren() - .ToList(); - - var currentList = item.Genres.ToList(); + var currentList = item.Genres; - item.Genres = items.SelectMany(i => i.Genres) + item.Genres = item.GetLinkedChildren().SelectMany(i => i.Genres) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 73a568ca97..443699b5a3 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -261,9 +261,10 @@ namespace MediaBrowser.Server.Mono { var args = Environment.GetCommandLineArgs() .Skip(1) - .Select(NormalizeCommandLineArgument); + .Select(NormalizeCommandLineArgument) + .ToArray(); - commandLineArgsString = string.Join(" ", args.ToArray()); + commandLineArgsString = string.Join(" ", args); } _logger.Info("Executable: {0}", module); diff --git a/MediaBrowser.ServerApplication/Native/LoopUtil.cs b/MediaBrowser.ServerApplication/Native/LoopUtil.cs index 7c74712312..0efdba389d 100644 --- a/MediaBrowser.ServerApplication/Native/LoopUtil.cs +++ b/MediaBrowser.ServerApplication/Native/LoopUtil.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.XbmcMetadata/EntryPoint.cs b/MediaBrowser.XbmcMetadata/EntryPoint.cs index ac5313a291..b1c687a6e3 100644 --- a/MediaBrowser.XbmcMetadata/EntryPoint.cs +++ b/MediaBrowser.XbmcMetadata/EntryPoint.cs @@ -8,7 +8,6 @@ using MediaBrowser.Model.Logging; using MediaBrowser.XbmcMetadata.Configuration; using MediaBrowser.XbmcMetadata.Savers; using System; -using System.Linq; using MediaBrowser.Controller.Dto; namespace MediaBrowser.XbmcMetadata diff --git a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs index f9ca238c7e..85f9f92baa 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.Linq; +using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Providers; @@ -81,7 +82,9 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val) && movie != null) { - movie.Artists.Add(val); + var list = movie.Artists.ToList(); + list.Add(val); + movie.Artists = list.ToArray(); } break; diff --git a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs index ec53b3bc4c..f9f9c9b98a 100644 --- a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs @@ -57,10 +57,9 @@ namespace MediaBrowser.XbmcMetadata.Savers private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - private void AddTracks(IEnumerable /// The to validate. - System.Collections.Generic.IEnumerable GetValidationErrors(SsdpRootDevice device); + System.Collections.Generic.List GetValidationErrors(SsdpRootDevice device); /// /// Returns an enumerable set of strings, each one being a description of an invalid property on the specified device. /// /// The to validate. - System.Collections.Generic.IEnumerable GetValidationErrors(SsdpDevice device); + System.Collections.Generic.List GetValidationErrors(SsdpDevice device); /// /// Validates the specified device and throws an if there are any validation errors. diff --git a/RSSDP/RequestReceivedEventArgs.cs b/RSSDP/RequestReceivedEventArgs.cs index 03c059634f..f4e3677605 100644 --- a/RSSDP/RequestReceivedEventArgs.cs +++ b/RSSDP/RequestReceivedEventArgs.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Text; diff --git a/RSSDP/ResponseReceivedEventArgs.cs b/RSSDP/ResponseReceivedEventArgs.cs index c983fa204a..f67d5da90b 100644 --- a/RSSDP/ResponseReceivedEventArgs.cs +++ b/RSSDP/ResponseReceivedEventArgs.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Text; diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs index 91004b76fe..a4be24ebfe 100644 --- a/RSSDP/SsdpCommunicationsServer.cs +++ b/RSSDP/SsdpCommunicationsServer.cs @@ -364,7 +364,7 @@ namespace Rssdp.Infrastructure if (_enableMultiSocketBinding) { - foreach (var address in _networkManager.GetLocalIpAddresses().ToList()) + foreach (var address in _networkManager.GetLocalIpAddresses()) { try { diff --git a/RSSDP/SsdpConstants.cs b/RSSDP/SsdpConstants.cs index c839d9e0bf..87f01f9e0c 100644 --- a/RSSDP/SsdpConstants.cs +++ b/RSSDP/SsdpConstants.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDevice.cs b/RSSDP/SsdpDevice.cs index a595742d00..cda11f0a46 100644 --- a/RSSDP/SsdpDevice.cs +++ b/RSSDP/SsdpDevice.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; @@ -283,7 +282,7 @@ namespace Rssdp /// /// /// - public IEnumerable Devices + public IList Devices { get; private set; @@ -466,7 +465,7 @@ namespace Rssdp private static void WriteIcons(XmlWriter writer, SsdpDevice device) { - if (device.Icons.Any()) + if (device.Icons.Count > 0) { writer.WriteStartElement("iconList"); @@ -489,7 +488,7 @@ namespace Rssdp private void WriteChildDevices(XmlWriter writer, SsdpDevice parentDevice) { - if (parentDevice.Devices.Any()) + if (parentDevice.Devices.Count > 0) { writer.WriteStartElement("deviceList"); diff --git a/RSSDP/SsdpDeviceExtensions.cs b/RSSDP/SsdpDeviceExtensions.cs index 0ad710a6b0..6e1b456461 100644 --- a/RSSDP/SsdpDeviceExtensions.cs +++ b/RSSDP/SsdpDeviceExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpDeviceIcon.cs b/RSSDP/SsdpDeviceIcon.cs index 4ffda58ff9..3ed707c80a 100644 --- a/RSSDP/SsdpDeviceIcon.cs +++ b/RSSDP/SsdpDeviceIcon.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDeviceLocator.cs b/RSSDP/SsdpDeviceLocator.cs index 3ea17237df..8fe4d4a144 100644 --- a/RSSDP/SsdpDeviceLocator.cs +++ b/RSSDP/SsdpDeviceLocator.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using MediaBrowser.Model.Net; using MediaBrowser.Model.Threading; diff --git a/RSSDP/SsdpDeviceLocatorBase.cs b/RSSDP/SsdpDeviceLocatorBase.cs index 1adb95cdf5..d1eaef88af 100644 --- a/RSSDP/SsdpDeviceLocatorBase.cs +++ b/RSSDP/SsdpDeviceLocatorBase.cs @@ -127,7 +127,7 @@ namespace Rssdp.Infrastructure } catch (Exception ex) { - + } } @@ -543,17 +543,9 @@ namespace Rssdp.Infrastructure } } - private IEnumerable GetUnexpiredDevices() - { - lock (_Devices) - { - return (from device in _Devices where !device.IsExpired() select device).ToArray(); - } - } - private bool DeviceDied(string deviceUsn, bool expired) { - IEnumerable existingDevices = null; + List existingDevices = null; lock (_Devices) { existingDevices = FindExistingDeviceNotifications(_Devices, deviceUsn); @@ -565,7 +557,7 @@ namespace Rssdp.Infrastructure } } - if (existingDevices != null && existingDevices.Any()) + if (existingDevices != null && existingDevices.Count > 0) { foreach (var removedDevice in existingDevices) { @@ -591,12 +583,29 @@ namespace Rssdp.Infrastructure private static DiscoveredSsdpDevice FindExistingDeviceNotification(IEnumerable devices, string notificationType, string usn) { - return (from d in devices where d.NotificationType == notificationType && d.Usn == usn select d).FirstOrDefault(); + foreach (var d in devices) + { + if (d.NotificationType == notificationType && d.Usn == usn) + { + return d; + } + } + return null; } - private static IEnumerable FindExistingDeviceNotifications(IList devices, string usn) + private static List FindExistingDeviceNotifications(IList devices, string usn) { - return (from d in devices where d.Usn == usn select d).ToArray(); + var list = new List(); + + foreach (var d in devices) + { + if (d.Usn == usn) + { + list.Add(d); + } + } + + return list; } #endregion diff --git a/RSSDP/SsdpDeviceProperties.cs b/RSSDP/SsdpDeviceProperties.cs index 850dfb0ba8..ae5309da58 100644 --- a/RSSDP/SsdpDeviceProperties.cs +++ b/RSSDP/SsdpDeviceProperties.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpDeviceProperty.cs b/RSSDP/SsdpDeviceProperty.cs index 3a8dd2ec7f..3abcfb9aa3 100644 --- a/RSSDP/SsdpDeviceProperty.cs +++ b/RSSDP/SsdpDeviceProperty.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDevicePublisher.cs b/RSSDP/SsdpDevicePublisher.cs index 1c17c78372..2aa1437750 100644 --- a/RSSDP/SsdpDevicePublisher.cs +++ b/RSSDP/SsdpDevicePublisher.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using MediaBrowser.Model.Net; using MediaBrowser.Model.Threading; diff --git a/RSSDP/SsdpEmbeddedDevice.cs b/RSSDP/SsdpEmbeddedDevice.cs index c03106b2dd..28948f9506 100644 --- a/RSSDP/SsdpEmbeddedDevice.cs +++ b/RSSDP/SsdpEmbeddedDevice.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpRootDevice.cs b/RSSDP/SsdpRootDevice.cs index faf851bcbe..5b7d0f4548 100644 --- a/RSSDP/SsdpRootDevice.cs +++ b/RSSDP/SsdpRootDevice.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Xml; using Rssdp.Infrastructure; diff --git a/RSSDP/UPnP10DeviceValidator.cs b/RSSDP/UPnP10DeviceValidator.cs index f802b7639e..2a8a9ccd28 100644 --- a/RSSDP/UPnP10DeviceValidator.cs +++ b/RSSDP/UPnP10DeviceValidator.cs @@ -26,11 +26,11 @@ namespace Rssdp.Infrastructure /// The to validate. /// Thrown if the argument is null. /// A non-null enumerable set of strings, empty if there are no validation errors, otherwise each string represents a discrete problem. - public IEnumerable GetValidationErrors(SsdpRootDevice device) + public List GetValidationErrors(SsdpRootDevice device) { if (device == null) throw new ArgumentNullException("device"); - var retVal = GetValidationErrors((SsdpDevice)device) as IList; + var retVal = GetValidationErrors((SsdpDevice)device); if (device.Location == null) retVal.Add("Location cannot be null."); @@ -49,7 +49,7 @@ namespace Rssdp.Infrastructure /// The to validate. /// Thrown if the argument is null. /// A non-null enumerable set of strings, empty if there are no validation errors, otherwise each string represents a discrete problem. - public IEnumerable GetValidationErrors(SsdpDevice device) + public List GetValidationErrors(SsdpDevice device) { if (device == null) throw new ArgumentNullException("device"); @@ -110,7 +110,7 @@ namespace Rssdp.Infrastructure if (String.IsNullOrEmpty(device.ModelName)) retVal.Add("ModelName is required."); - if (device.Icons.Any()) + if (device.Icons.Count > 0) ValidateIcons(device, retVal); ValidateChildDevices(device, retVal); @@ -127,7 +127,7 @@ namespace Rssdp.Infrastructure public void ThrowIfDeviceInvalid(SsdpDevice device) { var errors = this.GetValidationErrors(device); - if (errors != null && errors.Any()) throw new InvalidOperationException("Invalid device settings : " + String.Join(Environment.NewLine, errors)); + if (errors != null && errors.Count > 0) throw new InvalidOperationException("Invalid device settings : " + String.Join(Environment.NewLine, errors)); } #endregion diff --git a/SocketHttpListener/Net/BoundaryType.cs b/SocketHttpListener/Net/BoundaryType.cs index c3ac00c0fd..f1e799f63c 100644 --- a/SocketHttpListener/Net/BoundaryType.cs +++ b/SocketHttpListener/Net/BoundaryType.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/CookieHelper.cs b/SocketHttpListener/Net/CookieHelper.cs index 470507d6b7..a32131956f 100644 --- a/SocketHttpListener/Net/CookieHelper.cs +++ b/SocketHttpListener/Net/CookieHelper.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/EndPointManager.cs b/SocketHttpListener/Net/EndPointManager.cs index 6a00ed360a..ddb110ec16 100644 --- a/SocketHttpListener/Net/EndPointManager.cs +++ b/SocketHttpListener/Net/EndPointManager.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Reflection; using System.Threading.Tasks; @@ -83,7 +82,9 @@ namespace SocketHttpListener.Net { try { - addr = (await networkManager.GetHostAddressesAsync(host).ConfigureAwait(false)).FirstOrDefault() ?? + var all = (await networkManager.GetHostAddressesAsync(host).ConfigureAwait(false)); + + addr = (all.Length == 0 ? null : all[0]) ?? GetIpAnyAddress(listener); } catch diff --git a/SocketHttpListener/Net/EntitySendFormat.cs b/SocketHttpListener/Net/EntitySendFormat.cs index 6e585bdc9b..9caee3e112 100644 --- a/SocketHttpListener/Net/EntitySendFormat.cs +++ b/SocketHttpListener/Net/EntitySendFormat.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs index 83fcc09cae..34953b569a 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpListenerResponse.cs b/SocketHttpListener/Net/HttpListenerResponse.cs index fc57e84857..1cbd6165e7 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpRequestStream.Managed.cs b/SocketHttpListener/Net/HttpRequestStream.Managed.cs index 92f4bbb02d..c9c148b150 100644 --- a/SocketHttpListener/Net/HttpRequestStream.Managed.cs +++ b/SocketHttpListener/Net/HttpRequestStream.Managed.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.ExceptionServices; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpRequestStream.cs b/SocketHttpListener/Net/HttpRequestStream.cs index c54da44a17..f10c04a4f1 100644 --- a/SocketHttpListener/Net/HttpRequestStream.cs +++ b/SocketHttpListener/Net/HttpRequestStream.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs index 116c3280a7..b700c293d7 100644 --- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs +++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; using System.Net.Sockets; using System.Runtime.ExceptionServices; diff --git a/SocketHttpListener/Net/HttpResponseStream.cs b/SocketHttpListener/Net/HttpResponseStream.cs index f7140be66c..5b7fa417f3 100644 --- a/SocketHttpListener/Net/HttpResponseStream.cs +++ b/SocketHttpListener/Net/HttpResponseStream.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpStatusDescription.cs b/SocketHttpListener/Net/HttpStatusDescription.cs index 8d490c5117..9cc4a8e8ce 100644 --- a/SocketHttpListener/Net/HttpStatusDescription.cs +++ b/SocketHttpListener/Net/HttpStatusDescription.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/UriScheme.cs b/SocketHttpListener/Net/UriScheme.cs index eb13619c9d..35b01e0e55 100644 --- a/SocketHttpListener/Net/UriScheme.cs +++ b/SocketHttpListener/Net/UriScheme.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs index 66e159ccb7..d82dc68163 100644 --- a/SocketHttpListener/Net/WebHeaderCollection.cs +++ b/SocketHttpListener/Net/WebHeaderCollection.cs @@ -131,13 +131,13 @@ namespace SocketHttpListener.Net base.Add(headerName, headerValue); } - internal string[] GetValues_internal(string header, bool split) + internal List GetValues_internal(string header, bool split) { if (header == null) throw new ArgumentNullException("header"); - string[] values = base.GetValues(header); - if (values == null || values.Length == 0) + var values = base.GetValues(header); + if (values == null || values.Count == 0) return null; if (split && IsMultiValue(header)) @@ -155,7 +155,7 @@ namespace SocketHttpListener.Net if (separated == null) { - separated = new List(values.Length + 1); + separated = new List(values.Count + 1); foreach (var v in values) { if (v == value) @@ -177,13 +177,13 @@ namespace SocketHttpListener.Net } if (separated != null) - return separated.ToArray(separated.Count); + return separated; } return values; } - public override string[] GetValues(string header) + public override List GetValues(string header) { return GetValues_internal(header, true); } diff --git a/SocketHttpListener/Net/WebHeaderEncoding.cs b/SocketHttpListener/Net/WebHeaderEncoding.cs index 64330c1b43..4a080179ea 100644 --- a/SocketHttpListener/Net/WebHeaderEncoding.cs +++ b/SocketHttpListener/Net/WebHeaderEncoding.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Primitives/ICertificate.cs b/SocketHttpListener/Primitives/ICertificate.cs index 1289da13d7..ec21e9445d 100644 --- a/SocketHttpListener/Primitives/ICertificate.cs +++ b/SocketHttpListener/Primitives/ICertificate.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Primitives/IStreamFactory.cs b/SocketHttpListener/Primitives/IStreamFactory.cs index 57e21e31bc..4b623b940f 100644 --- a/SocketHttpListener/Primitives/IStreamFactory.cs +++ b/SocketHttpListener/Primitives/IStreamFactory.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; using MediaBrowser.Model.Net; diff --git a/SocketHttpListener/Primitives/ITextEncoding.cs b/SocketHttpListener/Primitives/ITextEncoding.cs index b10145687b..2c25a308c6 100644 --- a/SocketHttpListener/Primitives/ITextEncoding.cs +++ b/SocketHttpListener/Primitives/ITextEncoding.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; using MediaBrowser.Model.Text;