aboutsummaryrefslogtreecommitdiff
path: root/RSSDP
diff options
context:
space:
mode:
authortelans <telans@protonmail.com>2020-06-20 20:35:29 +1200
committertelans <telans@protonmail.com>2020-06-20 20:35:29 +1200
commit98db8f72e01b608e6c384ecf5b107fc2d105b652 (patch)
tree8099ba47507cfa9f1ff9b6e456cf854108298a63 /RSSDP
parent8e3d8748021fe0336e2fc1211810cc9bbe2c8850 (diff)
fix SA1503 for one line if statements
Diffstat (limited to 'RSSDP')
-rw-r--r--RSSDP/DeviceAvailableEventArgs.cs5
-rw-r--r--RSSDP/DeviceEventArgs.cs5
-rw-r--r--RSSDP/DeviceUnavailableEventArgs.cs5
-rw-r--r--RSSDP/DisposableManagedObjectBase.cs5
-rw-r--r--RSSDP/HttpParserBase.cs27
-rw-r--r--RSSDP/HttpRequestParser.cs16
-rw-r--r--RSSDP/HttpResponseParser.cs16
-rw-r--r--RSSDP/IEnumerableExtensions.cs11
-rw-r--r--RSSDP/SsdpCommunicationsServer.cs21
-rw-r--r--RSSDP/SsdpDevice.cs22
-rw-r--r--RSSDP/SsdpDeviceLocator.cs84
-rw-r--r--RSSDP/SsdpDevicePublisher.cs75
12 files changed, 240 insertions, 52 deletions
diff --git a/RSSDP/DeviceAvailableEventArgs.cs b/RSSDP/DeviceAvailableEventArgs.cs
index 9c57471ca..b7d22a7df 100644
--- a/RSSDP/DeviceAvailableEventArgs.cs
+++ b/RSSDP/DeviceAvailableEventArgs.cs
@@ -22,7 +22,10 @@ namespace Rssdp
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>
public DeviceAvailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool isNewlyDiscovered)
{
- if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice));
+ if (discoveredDevice == null)
+ {
+ throw new ArgumentNullException(nameof(discoveredDevice));
+ }
_DiscoveredDevice = discoveredDevice;
_IsNewlyDiscovered = isNewlyDiscovered;
diff --git a/RSSDP/DeviceEventArgs.cs b/RSSDP/DeviceEventArgs.cs
index b124527ca..2455ccbfa 100644
--- a/RSSDP/DeviceEventArgs.cs
+++ b/RSSDP/DeviceEventArgs.cs
@@ -16,7 +16,10 @@ namespace Rssdp
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="device"/> argument is null.</exception>
public DeviceEventArgs(SsdpDevice device)
{
- if (device == null) throw new ArgumentNullException(nameof(device));
+ if (device == null)
+ {
+ throw new ArgumentNullException(nameof(device));
+ }
_Device = device;
}
diff --git a/RSSDP/DeviceUnavailableEventArgs.cs b/RSSDP/DeviceUnavailableEventArgs.cs
index cee59268d..94248f39f 100644
--- a/RSSDP/DeviceUnavailableEventArgs.cs
+++ b/RSSDP/DeviceUnavailableEventArgs.cs
@@ -19,7 +19,10 @@ namespace Rssdp
/// <exception cref="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));
+ if (discoveredDevice == null)
+ {
+ throw new ArgumentNullException(nameof(discoveredDevice));
+ }
_DiscoveredDevice = discoveredDevice;
_Expired = expired;
diff --git a/RSSDP/DisposableManagedObjectBase.cs b/RSSDP/DisposableManagedObjectBase.cs
index befa4ccff..628572b17 100644
--- a/RSSDP/DisposableManagedObjectBase.cs
+++ b/RSSDP/DisposableManagedObjectBase.cs
@@ -23,7 +23,10 @@ namespace Rssdp.Infrastructure
/// <seealso cref="Dispose()"/>
protected virtual void ThrowIfDisposed()
{
- if (this.IsDisposed) throw new ObjectDisposedException(this.GetType().FullName);
+ if (this.IsDisposed)
+ {
+ throw new ObjectDisposedException(this.GetType().FullName);
+ }
}
/// <summary>
diff --git a/RSSDP/HttpParserBase.cs b/RSSDP/HttpParserBase.cs
index ff97b6db8..058bfbf55 100644
--- a/RSSDP/HttpParserBase.cs
+++ b/RSSDP/HttpParserBase.cs
@@ -31,9 +31,20 @@ namespace Rssdp.Infrastructure
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Honestly, it's fine. MemoryStream doesn't mind.")]
protected virtual void Parse(T message, System.Net.Http.Headers.HttpHeaders headers, string data)
{
- if (data == null) throw new ArgumentNullException(nameof(data));
- if (data.Length == 0) throw new ArgumentException("data cannot be an empty string.", nameof(data));
- if (!LineTerminators.Any(data.Contains)) throw new ArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.", nameof(data));
+ if (data == null)
+ {
+ throw new ArgumentNullException(nameof(data));
+ }
+
+ if (data.Length == 0)
+ {
+ throw new ArgumentException("data cannot be an empty string.", nameof(data));
+ }
+
+ if (!LineTerminators.Any(data.Contains))
+ {
+ throw new ArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.", nameof(data));
+ }
using (var retVal = new ByteArrayContent(Array.Empty<byte>()))
{
@@ -66,10 +77,16 @@ namespace Rssdp.Infrastructure
/// <returns>A <see cref="Version"/> object containing the parsed version data.</returns>
protected Version ParseHttpVersion(string versionData)
{
- if (versionData == null) throw new ArgumentNullException(nameof(versionData));
+ if (versionData == null)
+ {
+ throw new ArgumentNullException(nameof(versionData));
+ }
var versionSeparatorIndex = versionData.IndexOf('/');
- if (versionSeparatorIndex <= 0 || versionSeparatorIndex == versionData.Length) throw new ArgumentException("request header line is invalid. Http Version not supplied or incorrect format.", nameof(versionData));
+ if (versionSeparatorIndex <= 0 || versionSeparatorIndex == versionData.Length)
+ {
+ throw new ArgumentException("request header line is invalid. Http Version not supplied or incorrect format.", nameof(versionData));
+ }
return Version.Parse(versionData.Substring(versionSeparatorIndex + 1));
}
diff --git a/RSSDP/HttpRequestParser.cs b/RSSDP/HttpRequestParser.cs
index 31f042791..6b27fc4df 100644
--- a/RSSDP/HttpRequestParser.cs
+++ b/RSSDP/HttpRequestParser.cs
@@ -45,11 +45,21 @@ namespace Rssdp.Infrastructure
/// <param name="message">Either a <see cref="HttpResponseMessage"/> or <see cref="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));
+ 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));
+ 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;
diff --git a/RSSDP/HttpResponseParser.cs b/RSSDP/HttpResponseParser.cs
index 02c548d72..0337b3e36 100644
--- a/RSSDP/HttpResponseParser.cs
+++ b/RSSDP/HttpResponseParser.cs
@@ -57,11 +57,21 @@ namespace Rssdp.Infrastructure
/// <param name="message">Either a <see cref="HttpResponseMessage"/> or <see cref="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));
+ 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));
+ if (parts.Length < 2)
+ {
+ throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(data));
+ }
message.Version = ParseHttpVersion(parts[0].Trim());
diff --git a/RSSDP/IEnumerableExtensions.cs b/RSSDP/IEnumerableExtensions.cs
index 371454893..1f0daad3e 100644
--- a/RSSDP/IEnumerableExtensions.cs
+++ b/RSSDP/IEnumerableExtensions.cs
@@ -8,8 +8,15 @@ namespace Rssdp.Infrastructure
{
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));
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (selector == null)
+ {
+ throw new ArgumentNullException(nameof(selector));
+ }
return !source.Any() ? source :
source.Concat(
diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs
index 12ecf24f3..31ca90424 100644
--- a/RSSDP/SsdpCommunicationsServer.cs
+++ b/RSSDP/SsdpCommunicationsServer.cs
@@ -80,8 +80,15 @@ namespace Rssdp.Infrastructure
/// <exception cref="ArgumentOutOfRangeException">The <paramref name="multicastTimeToLive"/> argument is less than or equal to zero.</exception>
public SsdpCommunicationsServer(ISocketFactory socketFactory, int localPort, int multicastTimeToLive, INetworkManager networkManager, ILogger logger, bool enableMultiSocketBinding)
{
- if (socketFactory == null) throw new ArgumentNullException(nameof(socketFactory));
- if (multicastTimeToLive <= 0) throw new ArgumentOutOfRangeException(nameof(multicastTimeToLive), "multicastTimeToLive must be greater than zero.");
+ if (socketFactory == null)
+ {
+ throw new ArgumentNullException(nameof(socketFactory));
+ }
+
+ if (multicastTimeToLive <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(multicastTimeToLive), "multicastTimeToLive must be greater than zero.");
+ }
_BroadcastListenSocketSynchroniser = new object();
_SendSocketSynchroniser = new object();
@@ -151,7 +158,10 @@ namespace Rssdp.Infrastructure
/// </summary>
public async Task SendMessage(byte[] messageData, IPEndPoint destination, IPAddress fromLocalIpAddress, CancellationToken cancellationToken)
{
- if (messageData == null) throw new ArgumentNullException(nameof(messageData));
+ if (messageData == null)
+ {
+ throw new ArgumentNullException(nameof(messageData));
+ }
ThrowIfDisposed();
@@ -234,7 +244,10 @@ namespace Rssdp.Infrastructure
/// </summary>
public async Task SendMulticastMessage(string message, int sendCount, IPAddress fromLocalIpAddress, CancellationToken cancellationToken)
{
- if (message == null) throw new ArgumentNullException(nameof(message));
+ if (message == null)
+ {
+ throw new ArgumentNullException(nameof(message));
+ }
byte[] messageData = Encoding.UTF8.GetBytes(message);
diff --git a/RSSDP/SsdpDevice.cs b/RSSDP/SsdpDevice.cs
index 5b7d782b5..42f95862c 100644
--- a/RSSDP/SsdpDevice.cs
+++ b/RSSDP/SsdpDevice.cs
@@ -259,9 +259,20 @@ namespace Rssdp
/// <seealso cref="DeviceAdded"/>
public void AddDevice(SsdpEmbeddedDevice device)
{
- if (device == null) throw new ArgumentNullException(nameof(device));
- if (device.RootDevice != null && device.RootDevice != this.ToRootDevice()) throw new InvalidOperationException("This device is already associated with a different root device (has been added as a child in another branch).");
- if (device == this) throw new InvalidOperationException("Can't add device to itself.");
+ if (device == null)
+ {
+ throw new ArgumentNullException(nameof(device));
+ }
+
+ if (device.RootDevice != null && device.RootDevice != this.ToRootDevice())
+ {
+ throw new InvalidOperationException("This device is already associated with a different root device (has been added as a child in another branch).");
+ }
+
+ if (device == this)
+ {
+ throw new InvalidOperationException("Can't add device to itself.");
+ }
bool wasAdded = false;
lock (_Devices)
@@ -287,7 +298,10 @@ namespace Rssdp
/// <seealso cref="DeviceRemoved"/>
public void RemoveDevice(SsdpEmbeddedDevice device)
{
- if (device == null) throw new ArgumentNullException(nameof(device));
+ if (device == null)
+ {
+ throw new ArgumentNullException(nameof(device));
+ }
bool wasRemoved = false;
lock (_Devices)
diff --git a/RSSDP/SsdpDeviceLocator.cs b/RSSDP/SsdpDeviceLocator.cs
index b117c0b1e..a774ee23c 100644
--- a/RSSDP/SsdpDeviceLocator.cs
+++ b/RSSDP/SsdpDeviceLocator.cs
@@ -27,7 +27,10 @@ namespace Rssdp.Infrastructure
/// </summary>
public SsdpDeviceLocator(ISsdpCommunicationsServer communicationsServer)
{
- if (communicationsServer == null) throw new ArgumentNullException(nameof(communicationsServer));
+ if (communicationsServer == null)
+ {
+ throw new ArgumentNullException(nameof(communicationsServer));
+ }
_CommunicationsServer = communicationsServer;
_CommunicationsServer.ResponseReceived += CommsServer_ResponseReceived;
@@ -140,10 +143,25 @@ namespace Rssdp.Infrastructure
private Task SearchAsync(string searchTarget, TimeSpan searchWaitTime, CancellationToken cancellationToken)
{
- if (searchTarget == null) throw new ArgumentNullException(nameof(searchTarget));
- if (searchTarget.Length == 0) throw new ArgumentException("searchTarget cannot be an empty string.", nameof(searchTarget));
- if (searchWaitTime.TotalSeconds < 0) throw new ArgumentException("searchWaitTime must be a positive time.");
- if (searchWaitTime.TotalSeconds > 0 && searchWaitTime.TotalSeconds <= 1) throw new ArgumentException("searchWaitTime must be zero (if you are not using the result and relying entirely in the events), or greater than one second.");
+ if (searchTarget == null)
+ {
+ throw new ArgumentNullException(nameof(searchTarget));
+ }
+
+ if (searchTarget.Length == 0)
+ {
+ throw new ArgumentException("searchTarget cannot be an empty string.", nameof(searchTarget));
+ }
+
+ if (searchWaitTime.TotalSeconds < 0)
+ {
+ throw new ArgumentException("searchWaitTime must be a positive time.");
+ }
+
+ if (searchWaitTime.TotalSeconds > 0 && searchWaitTime.TotalSeconds <= 1)
+ {
+ throw new ArgumentException("searchWaitTime must be zero (if you are not using the result and relying entirely in the events), or greater than one second.");
+ }
ThrowIfDisposed();
@@ -192,7 +210,10 @@ namespace Rssdp.Infrastructure
/// <seealso cref="DeviceAvailable"/>
protected virtual void OnDeviceAvailable(DiscoveredSsdpDevice device, bool isNewDevice, IPAddress localIpAddress)
{
- if (this.IsDisposed) return;
+ if (this.IsDisposed)
+ {
+ return;
+ }
var handlers = this.DeviceAvailable;
if (handlers != null)
@@ -210,11 +231,16 @@ namespace Rssdp.Infrastructure
/// <seealso cref="DeviceUnavailable"/>
protected virtual void OnDeviceUnavailable(DiscoveredSsdpDevice device, bool expired)
{
- if (this.IsDisposed) return;
+ if (this.IsDisposed)
+ {
+ return;
+ }
var handlers = this.DeviceUnavailable;
if (handlers != null)
+ {
handlers(this, new DeviceUnavailableEventArgs(device, expired));
+ }
}
/// <summary>
@@ -281,7 +307,10 @@ namespace Rssdp.Infrastructure
private void DeviceFound(DiscoveredSsdpDevice device, bool isNewDevice, IPAddress localIpAddress)
{
- if (!NotificationTypeMatchesFilter(device)) return;
+ if (!NotificationTypeMatchesFilter(device))
+ {
+ return;
+ }
OnDeviceAvailable(device, isNewDevice, localIpAddress);
}
@@ -318,7 +347,10 @@ namespace Rssdp.Infrastructure
private void ProcessSearchResponseMessage(HttpResponseMessage message, IPAddress localIpAddress)
{
- if (!message.IsSuccessStatusCode) return;
+ if (!message.IsSuccessStatusCode)
+ {
+ return;
+ }
var location = GetFirstHeaderUriValue("Location", message);
if (location != null)
@@ -339,13 +371,20 @@ namespace Rssdp.Infrastructure
private void ProcessNotificationMessage(HttpRequestMessage message, IPAddress localIpAddress)
{
- if (String.Compare(message.Method.Method, "Notify", StringComparison.OrdinalIgnoreCase) != 0) return;
+ if (String.Compare(message.Method.Method, "Notify", StringComparison.OrdinalIgnoreCase) != 0)
+ {
+ return;
+ }
var notificationType = GetFirstHeaderStringValue("NTS", message);
if (String.Compare(notificationType, SsdpConstants.SsdpKeepAliveNotification, StringComparison.OrdinalIgnoreCase) == 0)
+ {
ProcessAliveNotification(message, localIpAddress);
+ }
else if (String.Compare(notificationType, SsdpConstants.SsdpByeByeNotification, StringComparison.OrdinalIgnoreCase) == 0)
+ {
ProcessByeByeNotification(message);
+ }
}
private void ProcessAliveNotification(HttpRequestMessage message, IPAddress localIpAddress)
@@ -454,14 +493,20 @@ namespace Rssdp.Infrastructure
private TimeSpan CacheAgeFromHeader(System.Net.Http.Headers.CacheControlHeaderValue headerValue)
{
- if (headerValue == null) return TimeSpan.Zero;
+ if (headerValue == null)
+ {
+ return TimeSpan.Zero;
+ }
return (TimeSpan)(headerValue.MaxAge ?? headerValue.SharedMaxAge ?? TimeSpan.Zero);
}
private void RemoveExpiredDevicesFromCache()
{
- if (this.IsDisposed) return;
+ if (this.IsDisposed)
+ {
+ return;
+ }
DiscoveredSsdpDevice[] expiredDevices = null;
lock (_Devices)
@@ -470,7 +515,10 @@ namespace Rssdp.Infrastructure
foreach (var device in expiredDevices)
{
- if (this.IsDisposed) return;
+ if (this.IsDisposed)
+ {
+ return;
+ }
_Devices.Remove(device);
}
@@ -481,7 +529,10 @@ namespace Rssdp.Infrastructure
// problems.
foreach (var expiredUsn in (from expiredDevice in expiredDevices select expiredDevice.Usn).Distinct())
{
- if (this.IsDisposed) return;
+ if (this.IsDisposed)
+ {
+ return;
+ }
DeviceDied(expiredUsn, true);
}
@@ -495,7 +546,10 @@ namespace Rssdp.Infrastructure
existingDevices = FindExistingDeviceNotifications(_Devices, deviceUsn);
foreach (var existingDevice in existingDevices)
{
- if (this.IsDisposed) return true;
+ if (this.IsDisposed)
+ {
+ return true;
+ }
_Devices.Remove(existingDevice);
}
diff --git a/RSSDP/SsdpDevicePublisher.cs b/RSSDP/SsdpDevicePublisher.cs
index b4cf2fb48..1b64d230d 100644
--- a/RSSDP/SsdpDevicePublisher.cs
+++ b/RSSDP/SsdpDevicePublisher.cs
@@ -40,12 +40,35 @@ namespace Rssdp.Infrastructure
public SsdpDevicePublisher(ISsdpCommunicationsServer communicationsServer, INetworkManager networkManager,
string osName, string osVersion, bool sendOnlyMatchedHost)
{
- if (communicationsServer == null) throw new ArgumentNullException(nameof(communicationsServer));
- if (networkManager == null) throw new ArgumentNullException(nameof(networkManager));
- if (osName == null) throw new ArgumentNullException(nameof(osName));
- if (osName.Length == 0) throw new ArgumentException("osName cannot be an empty string.", nameof(osName));
- if (osVersion == null) throw new ArgumentNullException(nameof(osVersion));
- if (osVersion.Length == 0) throw new ArgumentException("osVersion cannot be an empty string.", nameof(osName));
+ if (communicationsServer == null)
+ {
+ throw new ArgumentNullException(nameof(communicationsServer));
+ }
+
+ if (networkManager == null)
+ {
+ throw new ArgumentNullException(nameof(networkManager));
+ }
+
+ if (osName == null)
+ {
+ throw new ArgumentNullException(nameof(osName));
+ }
+
+ if (osName.Length == 0)
+ {
+ throw new ArgumentException("osName cannot be an empty string.", nameof(osName));
+ }
+
+ if (osVersion == null)
+ {
+ throw new ArgumentNullException(nameof(osVersion));
+ }
+
+ if (osVersion.Length == 0)
+ {
+ throw new ArgumentException("osVersion cannot be an empty string.", nameof(osName));
+ }
_SupportPnpRootDevice = true;
_Devices = new List<SsdpRootDevice>();
@@ -82,7 +105,10 @@ namespace Rssdp.Infrastructure
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "t", Justification = "Capture task to local variable supresses compiler warning, but task is not really needed.")]
public void AddDevice(SsdpRootDevice device)
{
- if (device == null) throw new ArgumentNullException(nameof(device));
+ if (device == null)
+ {
+ throw new ArgumentNullException(nameof(device));
+ }
ThrowIfDisposed();
@@ -115,7 +141,10 @@ namespace Rssdp.Infrastructure
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="device"/> argument is null.</exception>
public async Task RemoveDevice(SsdpRootDevice device)
{
- if (device == null) throw new ArgumentNullException(nameof(device));
+ if (device == null)
+ {
+ throw new ArgumentNullException(nameof(device));
+ }
bool wasRemoved = false;
lock (_Devices)
@@ -227,10 +256,15 @@ namespace Rssdp.Infrastructure
// return;
}
- if (!Int32.TryParse(mx, out maxWaitInterval) || maxWaitInterval <= 0) return;
+ if (!Int32.TryParse(mx, out maxWaitInterval) || maxWaitInterval <= 0)
+ {
+ return;
+ }
if (maxWaitInterval > 120)
+ {
maxWaitInterval = _Random.Next(0, 120);
+ }
// Do not block synchronously as that may tie up a threadpool thread for several seconds.
Task.Delay(_Random.Next(16, (maxWaitInterval * 1000))).ContinueWith((parentTask) =>
@@ -240,13 +274,21 @@ namespace Rssdp.Infrastructure
lock (_Devices)
{
if (String.Compare(SsdpConstants.SsdpDiscoverAllSTHeader, searchTarget, StringComparison.OrdinalIgnoreCase) == 0)
+ {
devices = GetAllDevicesAsFlatEnumerable().ToArray();
+ }
else if (String.Compare(SsdpConstants.UpnpDeviceTypeRootDevice, searchTarget, StringComparison.OrdinalIgnoreCase) == 0 || (this.SupportPnpRootDevice && String.Compare(SsdpConstants.PnpDeviceTypeRootDevice, searchTarget, StringComparison.OrdinalIgnoreCase) == 0))
+ {
devices = _Devices.ToArray();
+ }
else if (searchTarget.Trim().StartsWith("uuid:", StringComparison.OrdinalIgnoreCase))
+ {
devices = (from device in GetAllDevicesAsFlatEnumerable() where String.Compare(device.Uuid, searchTarget.Substring(5), StringComparison.OrdinalIgnoreCase) == 0 select device).ToArray();
+ }
else if (searchTarget.StartsWith("urn:", StringComparison.OrdinalIgnoreCase))
+ {
devices = (from device in GetAllDevicesAsFlatEnumerable() where String.Compare(device.FullDeviceType, searchTarget, StringComparison.OrdinalIgnoreCase) == 0 select device).ToArray();
+ }
}
if (devices != null)
@@ -382,7 +424,10 @@ namespace Rssdp.Infrastructure
{
try
{
- if (IsDisposed) return;
+ if (IsDisposed)
+ {
+ return;
+ }
// WriteTrace("Begin Sending Alive Notifications For All Devices");
@@ -394,7 +439,10 @@ namespace Rssdp.Infrastructure
foreach (var device in devices)
{
- if (IsDisposed) return;
+ if (IsDisposed)
+ {
+ return;
+ }
SendAliveNotifications(device, true, CancellationToken.None);
}
@@ -547,7 +595,10 @@ namespace Rssdp.Infrastructure
private void CommsServer_RequestReceived(object sender, RequestReceivedEventArgs e)
{
- if (this.IsDisposed) return;
+ if (this.IsDisposed)
+ {
+ return;
+ }
if (string.Equals(e.Message.Method.Method, SsdpConstants.MSearchMethod, StringComparison.OrdinalIgnoreCase))
{