mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 22:17:25 -04:00
Reformatted the files with notes.
This commit is contained in:
parent
e2751d42e8
commit
846456b41e
20 changed files with 217 additions and 216 deletions
|
@ -77,7 +77,7 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ServiceAction GetCurrentConnectionInfo()
|
private static ServiceAction GetCurrentConnectionInfo()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -236,7 +236,7 @@ namespace Emby.Naming.Video
|
||||||
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
|
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
testFilename = testFilename.Substring(folderName.Length).Trim();
|
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;
|
return false;
|
||||||
|
|
|
@ -89,9 +89,10 @@ namespace Emby.Server.Implementations.Devices
|
||||||
|
|
||||||
public DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
|
public DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
if (fileSystem == null) {
|
if (fileSystem == null)
|
||||||
throw new ArgumentNullException(nameof(fileSystem));
|
{
|
||||||
}
|
throw new ArgumentNullException(nameof(fileSystem));
|
||||||
|
}
|
||||||
|
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
|
@ -332,7 +332,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dto.ParentBackdropImageTags = new []
|
dto.ParentBackdropImageTags = new[]
|
||||||
{
|
{
|
||||||
_imageProcessor.GetImageCacheTag(program, image)
|
_imageProcessor.GetImageCacheTag(program, image)
|
||||||
};
|
};
|
||||||
|
|
|
@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
throw new ArgumentNullException(nameof(buffer));
|
throw new ArgumentNullException(nameof(buffer));
|
||||||
|
|
||||||
if (offset + count < 0)
|
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)
|
if (offset + count > buffer.Length)
|
||||||
throw new ArgumentException("offset + count must not be greater than the length of buffer");
|
throw new ArgumentException("offset + count must not be greater than the length of buffer");
|
||||||
|
|
|
@ -459,7 +459,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(folderPath))
|
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))
|
if (string.IsNullOrEmpty(fileAbsolutePath))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -29,7 +29,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// <value>The scheduled task.</value>
|
/// <value>The scheduled task.</value>
|
||||||
public IScheduledTask ScheduledTask { get; private set; }
|
public IScheduledTask ScheduledTask { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the json serializer.
|
/// Gets or sets the json serializer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The json serializer.</value>
|
/// <value>The json serializer.</value>
|
||||||
|
|
|
@ -116,7 +116,6 @@ namespace Emby.Server.Implementations.Services
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(component)) continue;
|
if (string.IsNullOrEmpty(component)) continue;
|
||||||
|
|
||||||
|
|
||||||
if (StringContains(component, VariablePrefix)
|
if (StringContains(component, VariablePrefix)
|
||||||
&& component.IndexOf(ComponentSeperator) != -1)
|
&& component.IndexOf(ComponentSeperator) != -1)
|
||||||
{
|
{
|
||||||
|
@ -352,7 +351,7 @@ namespace Emby.Server.Implementations.Services
|
||||||
|
|
||||||
if (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath)
|
if (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Verbs.Contains(httpMethod, StringComparer.OrdinalIgnoreCase))
|
if (!Verbs.Contains(httpMethod, StringComparer.OrdinalIgnoreCase))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using System;
|
using System;
|
||||||
|
@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.Sorting
|
||||||
|
|
||||||
return hasSeries != null ? hasSeries.FindSeriesSortName() : null;
|
return hasSeries != null ? hasSeries.FindSeriesSortName() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name.
|
/// Gets the name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NLangDetect.Core.Extensions
|
namespace NLangDetect.Core.Extensions
|
||||||
{
|
{
|
||||||
public static class StringExtensions
|
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)
|
|
||||||
{
|
{
|
||||||
if (start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Argument must not be negative.");
|
/// <summary>
|
||||||
if (end < 0) throw new ArgumentOutOfRangeException(nameof(end), "Argument must not be negative.");
|
/// 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.
|
||||||
if (end > s.Length) throw new ArgumentOutOfRangeException(nameof(end), "Argument must not be greater than the input string's length.");
|
/// </summary>
|
||||||
if (start > end) throw new ArgumentOutOfRangeException(nameof(start), "Argument must not be greater than the 'end' argument.");
|
/// <param name="s"></param>
|
||||||
|
/// <param name="start">the start index, inclusive</param>
|
||||||
return s.Substring(start, end - start);
|
/// <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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Devices;
|
using MediaBrowser.Controller.Devices;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
|
@ -595,8 +595,10 @@ namespace MediaBrowser.Api.Playback
|
||||||
/// <param name="request">The stream request.</param>
|
/// <param name="request">The stream request.</param>
|
||||||
private void ParseStreamOptions(StreamRequest request)
|
private void ParseStreamOptions(StreamRequest request)
|
||||||
{
|
{
|
||||||
foreach (var param in Request.QueryString) {
|
foreach (var param in Request.QueryString)
|
||||||
if (char.IsLower(param.Name[0])) {
|
{
|
||||||
|
if (char.IsLower(param.Name[0]))
|
||||||
|
{
|
||||||
// This was probably not parsed initially and should be a StreamOptions
|
// This was probably not parsed initially and should be a StreamOptions
|
||||||
// TODO: This should be incorporated either in the lower framework for parsing requests
|
// TODO: This should be incorporated either in the lower framework for parsing requests
|
||||||
// or the generated URL should correctly serialize it
|
// or the generated URL should correctly serialize it
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(person.Name))
|
if (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));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize
|
// Normalize
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -155,7 +155,7 @@ namespace MediaBrowser.Controller.Library
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
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)
|
if (AdditionalLocations == null)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -320,7 +320,7 @@ namespace MediaBrowser.Providers.Omdb
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(seriesImdbId))
|
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;
|
var imdbParam = seriesImdbId.StartsWith("tt", StringComparison.OrdinalIgnoreCase) ? seriesImdbId : "tt" + seriesImdbId;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
@ -65,7 +65,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(metadataFile))
|
if (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);
|
var settings = XmlReaderSettingsFactory.Create(false);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ namespace Rssdp
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new instance for the specified <see cref="SsdpDevice"/>.
|
/// Constructs a new instance for the specified <see cref="SsdpDevice"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="device">The <see cref="SsdpDevice"/> associated with the event this argument class is being used for.</param>
|
/// <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>
|
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="device"/> argument is null.</exception>
|
||||||
public DeviceEventArgs(SsdpDevice device)
|
public DeviceEventArgs(SsdpDevice device)
|
||||||
{
|
{
|
||||||
if (device == null) throw new ArgumentNullException(nameof(device));
|
if (device == null) throw new ArgumentNullException(nameof(device));
|
||||||
|
|
||||||
_Device = device;
|
_Device = device;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Rssdp
|
namespace Rssdp
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event arguments for the <see cref="Rssdp.Infrastructure.SsdpDeviceLocatorBase.DeviceUnavailable"/> event.
|
/// Event arguments for the <see cref="Rssdp.Infrastructure.SsdpDeviceLocatorBase.DeviceUnavailable"/> event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class DeviceUnavailableEventArgs : EventArgs
|
public sealed class DeviceUnavailableEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
private readonly DiscoveredSsdpDevice _DiscoveredDevice;
|
private readonly DiscoveredSsdpDevice _DiscoveredDevice;
|
||||||
private readonly bool _Expired;
|
private readonly bool _Expired;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Full constructor.
|
/// Full constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the device that has become unavailable.</param>
|
/// <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>
|
/// <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>
|
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>
|
||||||
public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired)
|
public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired)
|
||||||
{
|
{
|
||||||
if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));
|
if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));
|
||||||
|
|
||||||
_DiscoveredDevice = discoveredDevice;
|
_DiscoveredDevice = discoveredDevice;
|
||||||
_Expired = expired;
|
_Expired = expired;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Properties
|
#region Public Properties
|
||||||
|
|
||||||
/// <summary>
|
/// <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.
|
/// 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>
|
/// </summary>
|
||||||
public bool Expired
|
public bool Expired
|
||||||
{
|
{
|
||||||
get { return _Expired; }
|
get { return _Expired; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A reference to a <see cref="Rssdp.DiscoveredSsdpDevice"/> instance containing the discovery details of the removed device.
|
/// A reference to a <see cref="Rssdp.DiscoveredSsdpDevice"/> instance containing the discovery details of the removed device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DiscoveredSsdpDevice DiscoveredDevice
|
public DiscoveredSsdpDevice DiscoveredDevice
|
||||||
{
|
{
|
||||||
get { return _DiscoveredDevice; }
|
get { return _DiscoveredDevice; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
@ -8,70 +8,70 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Rssdp.Infrastructure
|
namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses a string into a <see cref="System.Net.Http.HttpRequestMessage"/> or throws an exception.
|
/// Parses a string into a <see cref="System.Net.Http.HttpRequestMessage"/> or throws an exception.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class HttpRequestParser : HttpParserBase<HttpRequestMessage>
|
public sealed class HttpRequestParser : HttpParserBase<HttpRequestMessage>
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Fields & Constants
|
#region Fields & Constants
|
||||||
|
|
||||||
private readonly string[] ContentHeaderNames = new string[]
|
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"
|
"Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"
|
||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses the specified data into a <see cref="System.Net.Http.HttpRequestMessage"/> instance.
|
/// Parses the specified data into a <see cref="System.Net.Http.HttpRequestMessage"/> instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">A string containing the data to parse.</param>
|
/// <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>
|
/// <returns>A <see cref="System.Net.Http.HttpRequestMessage"/> instance containing the parsed data.</returns>
|
||||||
public override System.Net.Http.HttpRequestMessage Parse(string data)
|
public override System.Net.Http.HttpRequestMessage Parse(string data)
|
||||||
{
|
{
|
||||||
System.Net.Http.HttpRequestMessage retVal = null;
|
System.Net.Http.HttpRequestMessage retVal = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
retVal = new System.Net.Http.HttpRequestMessage();
|
retVal = new System.Net.Http.HttpRequestMessage();
|
||||||
|
|
||||||
Parse(retVal, retVal.Headers, data);
|
Parse(retVal, retVal.Headers, data);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (retVal != null)
|
if (retVal != null)
|
||||||
retVal.Dispose();
|
retVal.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Overrides
|
#region Overrides
|
||||||
|
|
||||||
/// <summary>
|
/// <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"/>.
|
/// 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>
|
/// </summary>
|
||||||
/// <param name="data">The first line of the HTTP message to be parsed.</param>
|
/// <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>
|
/// <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)
|
protected override void ParseStatusLine(string data, HttpRequestMessage message)
|
||||||
{
|
{
|
||||||
if (data == null) throw new ArgumentNullException(nameof(data));
|
if (data == null) throw new ArgumentNullException(nameof(data));
|
||||||
if (message == null) throw new ArgumentNullException(nameof(message));
|
if (message == null) throw new ArgumentNullException(nameof(message));
|
||||||
|
|
||||||
var parts = data.Split(' ');
|
var parts = data.Split(' ');
|
||||||
if (parts.Length < 2) throw new ArgumentException("Status line is invalid. Insufficient status parts.", nameof(data));
|
if (parts.Length < 2) throw new ArgumentException("Status line is invalid. Insufficient status parts.", nameof(data));
|
||||||
|
|
||||||
message.Method = new HttpMethod(parts[0].Trim());
|
message.Method = new HttpMethod(parts[0].Trim());
|
||||||
Uri requestUri;
|
Uri requestUri;
|
||||||
if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))
|
if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))
|
||||||
message.RequestUri = requestUri;
|
message.RequestUri = requestUri;
|
||||||
else
|
else
|
||||||
System.Diagnostics.Debug.WriteLine(parts[1]);
|
System.Diagnostics.Debug.WriteLine(parts[1]);
|
||||||
|
|
||||||
if (parts.Length >= 3)
|
if (parts.Length >= 3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
@ -8,82 +8,82 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Rssdp.Infrastructure
|
namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses a string into a <see cref="System.Net.Http.HttpResponseMessage"/> or throws an exception.
|
/// Parses a string into a <see cref="System.Net.Http.HttpResponseMessage"/> or throws an exception.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class HttpResponseParser : HttpParserBase<System.Net.Http.HttpResponseMessage>
|
public sealed class HttpResponseParser : HttpParserBase<System.Net.Http.HttpResponseMessage>
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Fields & Constants
|
#region Fields & Constants
|
||||||
|
|
||||||
private readonly string[] ContentHeaderNames = new string[]
|
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"
|
"Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"
|
||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses the specified data into a <see cref="System.Net.Http.HttpResponseMessage"/> instance.
|
/// Parses the specified data into a <see cref="System.Net.Http.HttpResponseMessage"/> instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">A string containing the data to parse.</param>
|
/// <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>
|
/// <returns>A <see cref="System.Net.Http.HttpResponseMessage"/> instance containing the parsed data.</returns>
|
||||||
public override HttpResponseMessage Parse(string data)
|
public override HttpResponseMessage Parse(string data)
|
||||||
{
|
{
|
||||||
System.Net.Http.HttpResponseMessage retVal = null;
|
System.Net.Http.HttpResponseMessage retVal = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
retVal = new System.Net.Http.HttpResponseMessage();
|
retVal = new System.Net.Http.HttpResponseMessage();
|
||||||
|
|
||||||
Parse(retVal, retVal.Headers, data);
|
Parse(retVal, retVal.Headers, data);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if (retVal != null)
|
if (retVal != null)
|
||||||
retVal.Dispose();
|
retVal.Dispose();
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Overrides Methods
|
#region Overrides Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a boolean indicating whether the specified HTTP header name represents a content header (true), or a message header (false).
|
/// Returns a boolean indicating whether the specified HTTP header name represents a content header (true), or a message header (false).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="headerName">A string containing the name of the header to return the type of.</param>
|
/// <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>
|
/// <returns>A boolean, true if th specified header relates to HTTP content, otherwise false.</returns>
|
||||||
protected override bool IsContentHeader(string headerName)
|
protected override bool IsContentHeader(string headerName)
|
||||||
{
|
{
|
||||||
return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase);
|
return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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"/>.
|
/// 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>
|
/// </summary>
|
||||||
/// <param name="data">The first line of the HTTP message to be parsed.</param>
|
/// <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>
|
/// <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)
|
protected override void ParseStatusLine(string data, HttpResponseMessage message)
|
||||||
{
|
{
|
||||||
if (data == null) throw new ArgumentNullException(nameof(data));
|
if (data == null) throw new ArgumentNullException(nameof(data));
|
||||||
if (message == null) throw new ArgumentNullException(nameof(message));
|
if (message == null) throw new ArgumentNullException(nameof(message));
|
||||||
|
|
||||||
var parts = data.Split(' ');
|
var parts = data.Split(' ');
|
||||||
if (parts.Length < 2) throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(data));
|
if (parts.Length < 2) throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(data));
|
||||||
|
|
||||||
message.Version = ParseHttpVersion(parts[0].Trim());
|
message.Version = ParseHttpVersion(parts[0].Trim());
|
||||||
|
|
||||||
int statusCode = -1;
|
int statusCode = -1;
|
||||||
if (!Int32.TryParse(parts[1].Trim(), out statusCode))
|
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));
|
throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));
|
||||||
|
|
||||||
message.StatusCode = (HttpStatusCode)statusCode;
|
message.StatusCode = (HttpStatusCode)statusCode;
|
||||||
|
|
||||||
if (parts.Length >= 3)
|
if (parts.Length >= 3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Rssdp.Infrastructure
|
namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
internal static class IEnumerableExtensions
|
internal static class IEnumerableExtensions
|
||||||
{
|
{
|
||||||
public static IEnumerable<T> SelectManyRecursive<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> selector)
|
public static IEnumerable<T> SelectManyRecursive<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> selector)
|
||||||
{
|
{
|
||||||
if (source == null) throw new ArgumentNullException(nameof(source));
|
if (source == null) throw new ArgumentNullException(nameof(source));
|
||||||
if (selector == null) throw new ArgumentNullException(nameof(selector));
|
if (selector == null) throw new ArgumentNullException(nameof(selector));
|
||||||
|
|
||||||
return !source.Any() ? source :
|
return !source.Any() ? source :
|
||||||
source.Concat(
|
source.Concat(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue