aboutsummaryrefslogtreecommitdiff
path: root/RSSDP
diff options
context:
space:
mode:
Diffstat (limited to 'RSSDP')
-rw-r--r--RSSDP/DeviceEventArgs.cs18
-rw-r--r--RSSDP/DeviceUnavailableEventArgs.cs106
-rw-r--r--RSSDP/HttpRequestParser.cs130
-rw-r--r--RSSDP/HttpResponseParser.cs154
-rw-r--r--RSSDP/IEnumerableExtensions.cs14
5 files changed, 211 insertions, 211 deletions
diff --git a/RSSDP/DeviceEventArgs.cs b/RSSDP/DeviceEventArgs.cs
index 0212d1d7c..55b23b68c 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.cs
index e01248fa5..ecba7c013 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.cs
index 7d611dea8..1af7f0d51 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.cs
index 9c1373f74..d864a8bb7 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.cs
index 950d561b0..c96542dca 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(