The Free Software Media System - Server Backend & API
Reformatted the files with notes.
Erwin de Haan846456b41e87
diff --git a/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs b/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.csindex d42184f8ea..674bc4c8ee 100644--- a/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs+++ b/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs@@ -77,7 +77,7 @@ namespace Emby.Dlna.ConnectionManagerreturn action;}-+private static ServiceAction GetCurrentConnectionInfo(){var action = new ServiceActiondiff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.csindex aa4bb61279..45d4593de2 100644--- a/Emby.Naming/Video/VideoListResolver.cs+++ b/Emby.Naming/Video/VideoListResolver.cs@@ -1,4 +1,4 @@-using Emby.Naming.Common;+using Emby.Naming.Common;using System;using System.Collections.Generic;using System.IO;@@ -236,7 +236,7 @@ namespace Emby.Naming.Videoif (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase)){testFilename = testFilename.Substring(folderName.Length).Trim();- return testFilename.StartsWith("-", StringComparison.OrdinalIgnoreCase)||Regex.Replace(testFilename, @"\[([^]]*)\]", "").Trim() == string.Empty;+ return testFilename.StartsWith("-", StringComparison.OrdinalIgnoreCase) || Regex.Replace(testFilename, @"\[([^]]*)\]", "").Trim() == string.Empty;}return false;diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.csindex 5630d7d3ce..4f5950ac73 100644--- a/Emby.Server.Implementations/Devices/DeviceId.cs+++ b/Emby.Server.Implementations/Devices/DeviceId.cs@@ -89,9 +89,10 @@ namespace Emby.Server.Implementations.Devicespublic DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem){- if (fileSystem == null) {- throw new ArgumentNullException(nameof(fileSystem));- }+ if (fileSystem == null)+ {+ throw new ArgumentNullException(nameof(fileSystem));+ }_appPaths = appPaths;_logger = logger;diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.csindex dbc7b16a22..7397d4b60f 100644--- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs+++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs@@ -332,7 +332,7 @@ namespace Emby.Server.Implementations.LiveTv{try{- dto.ParentBackdropImageTags = new []+ dto.ParentBackdropImageTags = new[]{_imageProcessor.GetImageCacheTag(program, image)};diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.csindex 1a33154f87..fd78dfa8e7 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs@@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerunthrow new ArgumentNullException(nameof(buffer));if (offset + count < 0)- throw new ArgumentOutOfRangeException(nameof(offset),"offset + count must not be negative");+ throw new ArgumentOutOfRangeException(nameof(offset), "offset + count must not be negative");if (offset + count > buffer.Length)throw new ArgumentException("offset + count must not be greater than the length of buffer");diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.csindex a5fa24fc82..38fbac0309 100644--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs@@ -459,7 +459,7 @@ namespace Emby.Server.Implementations.Playlists{if (string.IsNullOrEmpty(folderPath)){- throw new ArgumentException("Folder path was null or empty.",nameof(folderPath));+ throw new ArgumentException("Folder path was null or empty.", nameof(folderPath));}if (string.IsNullOrEmpty(fileAbsolutePath))diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.csindex 602eeb29be..c8d6f20229 100644--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs@@ -1,4 +1,4 @@-using System;+using System;using System.Collections.Generic;using System.IO;using System.Linq;@@ -29,7 +29,6 @@ namespace Emby.Server.Implementations.ScheduledTasks/// <value>The scheduled task.</value>public IScheduledTask ScheduledTask { get; private set; }- /// <summary>/// Gets or sets the json serializer./// </summary>/// <value>The json serializer.</value>diff --git a/Emby.Server.Implementations/Services/ServicePath.cs b/Emby.Server.Implementations/Services/ServicePath.csindex 4c98a3388b..0222b3782c 100644--- a/Emby.Server.Implementations/Services/ServicePath.cs+++ b/Emby.Server.Implementations/Services/ServicePath.cs@@ -116,7 +116,6 @@ namespace Emby.Server.Implementations.Services{if (string.IsNullOrEmpty(component)) continue;-if (StringContains(component, VariablePrefix)&& component.IndexOf(ComponentSeperator) != -1){@@ -352,7 +351,7 @@ namespace Emby.Server.Implementations.Servicesif (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath){- return false;+ return false;}if (!Verbs.Contains(httpMethod, StringComparer.OrdinalIgnoreCase))diff --git a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.csindex 32a8f6b457..1bbe30b955 100644--- a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs+++ b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs@@ -1,4 +1,4 @@-using MediaBrowser.Controller.Entities;+using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Sorting;using MediaBrowser.Model.Querying;using System;@@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.Sortingreturn hasSeries != null ? hasSeries.FindSeriesSortName() : null;}-+/// <summary>/// Gets the name./// </summary>diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.csindex c60757c02e..5db68bbf1c 100644--- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.cs+++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/StringExtensions.cs@@ -1,25 +1,25 @@-using System;+using System;namespace NLangDetect.Core.Extensions{- public static class StringExtensions- {- /// <summary>- /// Returns a new character sequence that is a subsequence of this sequence. The subsequence starts with the character at the specified index and ends with the character at index end - 1. The length of the returned sequence is end - start, so if start == end then an empty sequence is returned.- /// </summary>- /// <param name="s"></param>- /// <param name="start">the start index, inclusive</param>- /// <param name="end">the end index, exclusive</param>- /// <returns>the specified subsequence</returns>- /// <exception cref="IndexOutOfRangeException"> if start or end are negative, if end is greater than length(), or if start is greater than end</exception>- public static string SubSequence(this string s, int start, int end)+ public static class StringExtensions{- if (start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Argument must not be negative.");- if (end < 0) throw new ArgumentOutOfRangeException(nameof(end), "Argument must not be negative.");- if (end > s.Length) throw new ArgumentOutOfRangeException(nameof(end), "Argument must not be greater than the input string's length.");- if (start > end) throw new ArgumentOutOfRangeException(nameof(start), "Argument must not be greater than the 'end' argument.");-- return s.Substring(start, end - start);+ /// <summary>+ /// Returns a new character sequence that is a subsequence of this sequence. The subsequence starts with the character at the specified index and ends with the character at index end - 1. The length of the returned sequence is end - start, so if start == end then an empty sequence is returned.+ /// </summary>+ /// <param name="s"></param>+ /// <param name="start">the start index, inclusive</param>+ /// <param name="end">the end index, exclusive</param>+ /// <returns>the specified subsequence</returns>+ /// <exception cref="IndexOutOfRangeException"> if start or end are negative, if end is greater than length(), or if start is greater than end</exception>+ public static string SubSequence(this string s, int start, int end)+ {+ if (start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Argument must not be negative.");+ if (end < 0) throw new ArgumentOutOfRangeException(nameof(end), "Argument must not be negative.");+ if (end > s.Length) throw new ArgumentOutOfRangeException(nameof(end), "Argument must not be greater than the input string's length.");+ if (start > end) throw new ArgumentOutOfRangeException(nameof(start), "Argument must not be greater than the 'end' argument.");++ return s.Substring(start, end - start);+ }}- }}diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex 2e423c31e0..ba7f7070b6 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -1,4 +1,4 @@-using MediaBrowser.Common.Extensions;+using MediaBrowser.Common.Extensions;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Devices;using MediaBrowser.Controller.Dlna;@@ -595,8 +595,10 @@ namespace MediaBrowser.Api.Playback/// <param name="request">The stream request.</param>private void ParseStreamOptions(StreamRequest request){- foreach (var param in Request.QueryString) {- if (char.IsLower(param.Name[0])) {+ foreach (var param in Request.QueryString)+ {+ if (char.IsLower(param.Name[0]))+ {// This was probably not parsed initially and should be a StreamOptions// TODO: This should be incorporated either in the lower framework for parsing requests// or the generated URL should correctly serialize itdiff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.csindex 1f670b7528..d09ef3a15f 100644--- a/MediaBrowser.Controller/Entities/PeopleHelper.cs+++ b/MediaBrowser.Controller/Entities/PeopleHelper.cs@@ -1,4 +1,4 @@-using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Entities;using System;using System.Collections.Generic;using System.Linq;@@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Entitiesif (string.IsNullOrEmpty(person.Name)){- throw new ArgumentException("The person's name was empty or null.",nameof(person));+ throw new ArgumentException("The person's name was empty or null.", nameof(person));}// Normalizediff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.csindex 387540b812..4d1a4ed2f5 100644--- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs+++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs@@ -1,4 +1,4 @@-using MediaBrowser.Controller.Entities;+using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Providers;using System;using System.Collections.Generic;@@ -155,7 +155,7 @@ namespace MediaBrowser.Controller.Library{if (string.IsNullOrEmpty(path)){- throw new ArgumentException("The path was empty or null.",nameof(path));+ throw new ArgumentException("The path was empty or null.", nameof(path));}if (AdditionalLocations == null)diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.csindex 8d99f7b7f0..6aca093ecf 100644--- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs+++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs@@ -1,4 +1,4 @@-using MediaBrowser.Model.IO;+using MediaBrowser.Model.IO;using MediaBrowser.Common.Net;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Entities;@@ -320,7 +320,7 @@ namespace MediaBrowser.Providers.Omdb{if (string.IsNullOrWhiteSpace(seriesImdbId)){- throw new ArgumentException("The series IMDb ID was null or whitespace.",nameof(seriesImdbId));+ throw new ArgumentException("The series IMDb ID was null or whitespace.", nameof(seriesImdbId));}var imdbParam = seriesImdbId.StartsWith("tt", StringComparison.OrdinalIgnoreCase) ? seriesImdbId : "tt" + seriesImdbId;diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.csindex 4fdba39fa3..5390f50495 100644--- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs+++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs@@ -1,4 +1,4 @@-using MediaBrowser.Common.Configuration;+using MediaBrowser.Common.Configuration;using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Providers;using MediaBrowser.Model.Entities;@@ -65,7 +65,7 @@ namespace MediaBrowser.XbmcMetadata.Parsersif (string.IsNullOrEmpty(metadataFile)){- throw new ArgumentException("The metadata file was empty or null.",nameof(metadataFile));+ throw new ArgumentException("The metadata file was empty or null.", nameof(metadataFile));}var settings = XmlReaderSettingsFactory.Create(false);diff --git a/RSSDP/DeviceEventArgs.cs b/RSSDP/DeviceEventArgs.csindex 0212d1d7ce..55b23b68c9 100644--- a/RSSDP/DeviceEventArgs.cs+++ b/RSSDP/DeviceEventArgs.cs@@ -1,4 +1,4 @@-using System;+using System;using System.Collections.Generic;using System.Text;@@ -18,14 +18,14 @@ namespace Rssdp#region Constructors- /// <summary>- /// Constructs a new instance for the specified <see cref="SsdpDevice"/>.- /// </summary>- /// <param name="device">The <see cref="SsdpDevice"/> associated with the event this argument class is being used for.</param>- /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="device"/> argument is null.</exception>- public DeviceEventArgs(SsdpDevice device)- {- if (device == null) throw new ArgumentNullException(nameof(device));+ /// <summary>+ /// Constructs a new instance for the specified <see cref="SsdpDevice"/>.+ /// </summary>+ /// <param name="device">The <see cref="SsdpDevice"/> associated with the event this argument class is being used for.</param>+ /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="device"/> argument is null.</exception>+ public DeviceEventArgs(SsdpDevice device)+ {+ if (device == null) throw new ArgumentNullException(nameof(device));_Device = device;}diff --git a/RSSDP/DeviceUnavailableEventArgs.cs b/RSSDP/DeviceUnavailableEventArgs.csindex e01248fa5b..ecba7c0132 100644--- a/RSSDP/DeviceUnavailableEventArgs.cs+++ b/RSSDP/DeviceUnavailableEventArgs.cs@@ -1,59 +1,59 @@-using System;+using System;using System.Collections.Generic;using System.Text;using System.Threading.Tasks;namespace Rssdp{- /// <summary>- /// Event arguments for the <see cref="Rssdp.Infrastructure.SsdpDeviceLocatorBase.DeviceUnavailable"/> event.- /// </summary>- public sealed class DeviceUnavailableEventArgs : EventArgs- {-- #region Fields-- private readonly DiscoveredSsdpDevice _DiscoveredDevice;- private readonly bool _Expired;-- #endregion-- #region Constructors-- /// <summary>- /// Full constructor.- /// </summary>- /// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the device that has become unavailable.</param>- /// <param name="expired">A boolean value indicating whether this device is unavailable because it expired, or because it explicitly sent a byebye notification.. See <see cref="Expired"/> for more detail.</param>- /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>- public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired)- {- if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));-- _DiscoveredDevice = discoveredDevice;- _Expired = expired;- }-- #endregion-- #region Public Properties-- /// <summary>- /// Returns true if the device is considered unavailable because it's cached information expired before a new alive notification or search result was received. Returns false if the device is unavailable because it sent an explicit notification of it's unavailability.- /// </summary>- public bool Expired- {- get { return _Expired; }- }-- /// <summary>- /// A reference to a <see cref="Rssdp.DiscoveredSsdpDevice"/> instance containing the discovery details of the removed device.- /// </summary>- public DiscoveredSsdpDevice DiscoveredDevice- {- get { return _DiscoveredDevice; }- }-- #endregion- }-}\ No newline at end of file+ /// <summary>+ /// Event arguments for the <see cref="Rssdp.Infrastructure.SsdpDeviceLocatorBase.DeviceUnavailable"/> event.+ /// </summary>+ public sealed class DeviceUnavailableEventArgs : EventArgs+ {++ #region Fields++ private readonly DiscoveredSsdpDevice _DiscoveredDevice;+ private readonly bool _Expired;++ #endregion++ #region Constructors++ /// <summary>+ /// Full constructor.+ /// </summary>+ /// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the device that has become unavailable.</param>+ /// <param name="expired">A boolean value indicating whether this device is unavailable because it expired, or because it explicitly sent a byebye notification.. See <see cref="Expired"/> for more detail.</param>+ /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>+ public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired)+ {+ if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));++ _DiscoveredDevice = discoveredDevice;+ _Expired = expired;+ }++ #endregion++ #region Public Properties++ /// <summary>+ /// Returns true if the device is considered unavailable because it's cached information expired before a new alive notification or search result was received. Returns false if the device is unavailable because it sent an explicit notification of it's unavailability.+ /// </summary>+ public bool Expired+ {+ get { return _Expired; }+ }++ /// <summary>+ /// A reference to a <see cref="Rssdp.DiscoveredSsdpDevice"/> instance containing the discovery details of the removed device.+ /// </summary>+ public DiscoveredSsdpDevice DiscoveredDevice+ {+ get { return _DiscoveredDevice; }+ }++ #endregion+ }+}diff --git a/RSSDP/HttpRequestParser.cs b/RSSDP/HttpRequestParser.csindex 7d611dea86..1af7f0d515 100644--- a/RSSDP/HttpRequestParser.cs+++ b/RSSDP/HttpRequestParser.cs@@ -1,4 +1,4 @@-using System;+using System;using System.Collections.Generic;using System.Linq;using System.Net;@@ -8,70 +8,70 @@ using System.Threading.Tasks;namespace Rssdp.Infrastructure{- /// <summary>- /// Parses a string into a <see cref="System.Net.Http.HttpRequestMessage"/> or throws an exception.- /// </summary>- public sealed class HttpRequestParser : HttpParserBase<HttpRequestMessage>- {-- #region Fields & Constants-- private readonly string[] ContentHeaderNames = new string[]- {- "Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"- };-- #endregion-- #region Public Methods-- /// <summary>- /// Parses the specified data into a <see cref="System.Net.Http.HttpRequestMessage"/> instance.- /// </summary>- /// <param name="data">A string containing the data to parse.</param>- /// <returns>A <see cref="System.Net.Http.HttpRequestMessage"/> instance containing the parsed data.</returns>- public override System.Net.Http.HttpRequestMessage Parse(string data)- {- System.Net.Http.HttpRequestMessage retVal = null;-- try- {- retVal = new System.Net.Http.HttpRequestMessage();-- Parse(retVal, retVal.Headers, data);-- return retVal;- }- finally- {- if (retVal != null)- retVal.Dispose();- }- }-- #endregion-- #region Overrides-- /// <summary>- /// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the <paramref name="message"/>.- /// </summary>- /// <param name="data">The first line of the HTTP message to be parsed.</param>- /// <param name="message">Either a <see cref="System.Net.Http.HttpResponseMessage"/> or <see cref="System.Net.Http.HttpRequestMessage"/> to assign the parsed values to.</param>- protected override void ParseStatusLine(string data, HttpRequestMessage message)- {- if (data == null) throw new ArgumentNullException(nameof(data));- if (message == null) throw new ArgumentNullException(nameof(message));-- var parts = data.Split(' ');- if (parts.Length < 2) throw new ArgumentException("Status line is invalid. Insufficient status parts.", nameof(data));-- message.Method = new HttpMethod(parts[0].Trim());- Uri requestUri;- if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))- message.RequestUri = requestUri;- else- System.Diagnostics.Debug.WriteLine(parts[1]);+ /// <summary>+ /// Parses a string into a <see cref="System.Net.Http.HttpRequestMessage"/> or throws an exception.+ /// </summary>+ public sealed class HttpRequestParser : HttpParserBase<HttpRequestMessage>+ {++ #region Fields & Constants++ private readonly string[] ContentHeaderNames = new string[]+ {+ "Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"+ };++ #endregion++ #region Public Methods++ /// <summary>+ /// Parses the specified data into a <see cref="System.Net.Http.HttpRequestMessage"/> instance.+ /// </summary>+ /// <param name="data">A string containing the data to parse.</param>+ /// <returns>A <see cref="System.Net.Http.HttpRequestMessage"/> instance containing the parsed data.</returns>+ public override System.Net.Http.HttpRequestMessage Parse(string data)+ {+ System.Net.Http.HttpRequestMessage retVal = null;++ try+ {+ retVal = new System.Net.Http.HttpRequestMessage();++ Parse(retVal, retVal.Headers, data);++ return retVal;+ }+ finally+ {+ if (retVal != null)+ retVal.Dispose();+ }+ }++ #endregion++ #region Overrides++ /// <summary>+ /// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the <paramref name="message"/>.+ /// </summary>+ /// <param name="data">The first line of the HTTP message to be parsed.</param>+ /// <param name="message">Either a <see cref="System.Net.Http.HttpResponseMessage"/> or <see cref="System.Net.Http.HttpRequestMessage"/> to assign the parsed values to.</param>+ protected override void ParseStatusLine(string data, HttpRequestMessage message)+ {+ if (data == null) throw new ArgumentNullException(nameof(data));+ if (message == null) throw new ArgumentNullException(nameof(message));++ var parts = data.Split(' ');+ if (parts.Length < 2) throw new ArgumentException("Status line is invalid. Insufficient status parts.", nameof(data));++ message.Method = new HttpMethod(parts[0].Trim());+ Uri requestUri;+ if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))+ message.RequestUri = requestUri;+ else+ System.Diagnostics.Debug.WriteLine(parts[1]);if (parts.Length >= 3){diff --git a/RSSDP/HttpResponseParser.cs b/RSSDP/HttpResponseParser.csindex 9c1373f746..d864a8bb74 100644--- a/RSSDP/HttpResponseParser.cs+++ b/RSSDP/HttpResponseParser.cs@@ -1,4 +1,4 @@-using System;+using System;using System.Collections.Generic;using System.Linq;using System.Net;@@ -8,82 +8,82 @@ using System.Threading.Tasks;namespace Rssdp.Infrastructure{- /// <summary>- /// Parses a string into a <see cref="System.Net.Http.HttpResponseMessage"/> or throws an exception.- /// </summary>- public sealed class HttpResponseParser : HttpParserBase<System.Net.Http.HttpResponseMessage>- {-- #region Fields & Constants-- private readonly string[] ContentHeaderNames = new string[]- {- "Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"- };-- #endregion-- #region Public Methods-- /// <summary>- /// Parses the specified data into a <see cref="System.Net.Http.HttpResponseMessage"/> instance.- /// </summary>- /// <param name="data">A string containing the data to parse.</param>- /// <returns>A <see cref="System.Net.Http.HttpResponseMessage"/> instance containing the parsed data.</returns>- public override HttpResponseMessage Parse(string data)- {- System.Net.Http.HttpResponseMessage retVal = null;- try- {- retVal = new System.Net.Http.HttpResponseMessage();-- Parse(retVal, retVal.Headers, data);-- return retVal;- }- catch- {- if (retVal != null)- retVal.Dispose();-- throw;- }- }-- #endregion-- #region Overrides Methods-- /// <summary>- /// Returns a boolean indicating whether the specified HTTP header name represents a content header (true), or a message header (false).- /// </summary>- /// <param name="headerName">A string containing the name of the header to return the type of.</param>- /// <returns>A boolean, true if th specified header relates to HTTP content, otherwise false.</returns>- protected override bool IsContentHeader(string headerName)- {- return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase);- }-- /// <summary>- /// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the <paramref name="message"/>.- /// </summary>- /// <param name="data">The first line of the HTTP message to be parsed.</param>- /// <param name="message">Either a <see cref="System.Net.Http.HttpResponseMessage"/> or <see cref="System.Net.Http.HttpRequestMessage"/> to assign the parsed values to.</param>- protected override void ParseStatusLine(string data, HttpResponseMessage message)- {- if (data == null) throw new ArgumentNullException(nameof(data));- if (message == null) throw new ArgumentNullException(nameof(message));-- var parts = data.Split(' ');- if (parts.Length < 2) throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(data));-- message.Version = ParseHttpVersion(parts[0].Trim());-- int statusCode = -1;- if (!Int32.TryParse(parts[1].Trim(), out statusCode))- throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));-- message.StatusCode = (HttpStatusCode)statusCode;+ /// <summary>+ /// Parses a string into a <see cref="System.Net.Http.HttpResponseMessage"/> or throws an exception.+ /// </summary>+ public sealed class HttpResponseParser : HttpParserBase<System.Net.Http.HttpResponseMessage>+ {++ #region Fields & Constants++ private readonly string[] ContentHeaderNames = new string[]+ {+ "Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"+ };++ #endregion++ #region Public Methods++ /// <summary>+ /// Parses the specified data into a <see cref="System.Net.Http.HttpResponseMessage"/> instance.+ /// </summary>+ /// <param name="data">A string containing the data to parse.</param>+ /// <returns>A <see cref="System.Net.Http.HttpResponseMessage"/> instance containing the parsed data.</returns>+ public override HttpResponseMessage Parse(string data)+ {+ System.Net.Http.HttpResponseMessage retVal = null;+ try+ {+ retVal = new System.Net.Http.HttpResponseMessage();++ Parse(retVal, retVal.Headers, data);++ return retVal;+ }+ catch+ {+ if (retVal != null)+ retVal.Dispose();++ throw;+ }+ }++ #endregion++ #region Overrides Methods++ /// <summary>+ /// Returns a boolean indicating whether the specified HTTP header name represents a content header (true), or a message header (false).+ /// </summary>+ /// <param name="headerName">A string containing the name of the header to return the type of.</param>+ /// <returns>A boolean, true if th specified header relates to HTTP content, otherwise false.</returns>+ protected override bool IsContentHeader(string headerName)+ {+ return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase);+ }++ /// <summary>+ /// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the <paramref name="message"/>.+ /// </summary>+ /// <param name="data">The first line of the HTTP message to be parsed.</param>+ /// <param name="message">Either a <see cref="System.Net.Http.HttpResponseMessage"/> or <see cref="System.Net.Http.HttpRequestMessage"/> to assign the parsed values to.</param>+ protected override void ParseStatusLine(string data, HttpResponseMessage message)+ {+ if (data == null) throw new ArgumentNullException(nameof(data));+ if (message == null) throw new ArgumentNullException(nameof(message));++ var parts = data.Split(' ');+ if (parts.Length < 2) throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(data));++ message.Version = ParseHttpVersion(parts[0].Trim());++ int statusCode = -1;+ if (!Int32.TryParse(parts[1].Trim(), out statusCode))+ throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));++ message.StatusCode = (HttpStatusCode)statusCode;if (parts.Length >= 3){diff --git a/RSSDP/IEnumerableExtensions.cs b/RSSDP/IEnumerableExtensions.csindex 950d561b05..c96542dca4 100644--- a/RSSDP/IEnumerableExtensions.cs+++ b/RSSDP/IEnumerableExtensions.cs@@ -1,16 +1,16 @@-using System;+using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Rssdp.Infrastructure{- internal static class IEnumerableExtensions- {- public static IEnumerable<T> SelectManyRecursive<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> selector)- {- if (source == null) throw new ArgumentNullException(nameof(source));- if (selector == null) throw new ArgumentNullException(nameof(selector));+ internal static class IEnumerableExtensions+ {+ public static IEnumerable<T> SelectManyRecursive<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> selector)+ {+ if (source == null) throw new ArgumentNullException(nameof(source));+ if (selector == null) throw new ArgumentNullException(nameof(selector));return !source.Any() ? source :source.Concat(