aboutsummaryrefslogtreecommitdiff
path: root/RSSDP
diff options
context:
space:
mode:
Diffstat (limited to 'RSSDP')
-rw-r--r--RSSDP/HttpRequestParser.cs5
-rw-r--r--RSSDP/HttpResponseParser.cs5
-rw-r--r--RSSDP/SsdpCommunicationsServer.cs14
-rw-r--r--RSSDP/SsdpDevice.cs10
-rw-r--r--RSSDP/SsdpDeviceLocator.cs14
-rw-r--r--RSSDP/SsdpDevicePublisher.cs10
6 files changed, 14 insertions, 44 deletions
diff --git a/RSSDP/HttpRequestParser.cs b/RSSDP/HttpRequestParser.cs
index a1b4627a9..fab70eae2 100644
--- a/RSSDP/HttpRequestParser.cs
+++ b/RSSDP/HttpRequestParser.cs
@@ -33,10 +33,7 @@ namespace Rssdp.Infrastructure
}
finally
{
- if (retVal != null)
- {
- retVal.Dispose();
- }
+ retVal?.Dispose();
}
}
diff --git a/RSSDP/HttpResponseParser.cs b/RSSDP/HttpResponseParser.cs
index 71b7a7b99..c570c84cb 100644
--- a/RSSDP/HttpResponseParser.cs
+++ b/RSSDP/HttpResponseParser.cs
@@ -33,10 +33,7 @@ namespace Rssdp.Infrastructure
}
catch
{
- if (retVal != null)
- {
- retVal.Dispose();
- }
+ retVal?.Dispose();
throw;
}
diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs
index 001d2a55e..768fad5ec 100644
--- a/RSSDP/SsdpCommunicationsServer.cs
+++ b/RSSDP/SsdpCommunicationsServer.cs
@@ -512,22 +512,16 @@ namespace Rssdp.Infrastructure
}
var handlers = this.RequestReceived;
- if (handlers is not null)
- {
- handlers(this, new RequestReceivedEventArgs(data, remoteEndPoint, receivedOnlocalIPAddress));
- }
+ handlers?.Invoke(this, new RequestReceivedEventArgs(data, remoteEndPoint, receivedOnlocalIPAddress));
}
private void OnResponseReceived(HttpResponseMessage data, IPEndPoint endPoint, IPAddress localIPAddress)
{
var handlers = this.ResponseReceived;
- if (handlers is not null)
+ handlers?.Invoke(this, new ResponseReceivedEventArgs(data, endPoint)
{
- handlers(this, new ResponseReceivedEventArgs(data, endPoint)
- {
- LocalIPAddress = localIPAddress
- });
- }
+ LocalIPAddress = localIPAddress
+ });
}
}
}
diff --git a/RSSDP/SsdpDevice.cs b/RSSDP/SsdpDevice.cs
index 3e4261b6a..569d733ea 100644
--- a/RSSDP/SsdpDevice.cs
+++ b/RSSDP/SsdpDevice.cs
@@ -337,10 +337,7 @@ namespace Rssdp
protected virtual void OnDeviceAdded(SsdpEmbeddedDevice device)
{
var handlers = this.DeviceAdded;
- if (handlers != null)
- {
- handlers(this, new DeviceEventArgs(device));
- }
+ handlers?.Invoke(this, new DeviceEventArgs(device));
}
/// <summary>
@@ -352,10 +349,7 @@ namespace Rssdp
protected virtual void OnDeviceRemoved(SsdpEmbeddedDevice device)
{
var handlers = this.DeviceRemoved;
- if (handlers != null)
- {
- handlers(this, new DeviceEventArgs(device));
- }
+ handlers?.Invoke(this, new DeviceEventArgs(device));
}
}
}
diff --git a/RSSDP/SsdpDeviceLocator.cs b/RSSDP/SsdpDeviceLocator.cs
index 1afb86de4..78784f4ec 100644
--- a/RSSDP/SsdpDeviceLocator.cs
+++ b/RSSDP/SsdpDeviceLocator.cs
@@ -227,13 +227,10 @@ namespace Rssdp.Infrastructure
}
var handlers = this.DeviceAvailable;
- if (handlers is not null)
+ handlers?.Invoke(this, new DeviceAvailableEventArgs(device, isNewDevice)
{
- handlers(this, new DeviceAvailableEventArgs(device, isNewDevice)
- {
- RemoteIPAddress = IPAddress
- });
- }
+ RemoteIPAddress = IPAddress
+ });
}
/// <summary>
@@ -250,10 +247,7 @@ namespace Rssdp.Infrastructure
}
var handlers = this.DeviceUnavailable;
- if (handlers is not null)
- {
- handlers(this, new DeviceUnavailableEventArgs(device, expired));
- }
+ handlers?.Invoke(this, new DeviceUnavailableEventArgs(device, expired));
}
/// <summary>
diff --git a/RSSDP/SsdpDevicePublisher.cs b/RSSDP/SsdpDevicePublisher.cs
index d4a70a975..cdc73d552 100644
--- a/RSSDP/SsdpDevicePublisher.cs
+++ b/RSSDP/SsdpDevicePublisher.cs
@@ -527,10 +527,7 @@ namespace Rssdp.Infrastructure
{
var timer = _RebroadcastAliveNotificationsTimer;
_RebroadcastAliveNotificationsTimer = null;
- if (timer is not null)
- {
- timer.Dispose();
- }
+ timer?.Dispose();
}
private TimeSpan GetMinimumNonZeroCacheLifetime()
@@ -564,10 +561,7 @@ namespace Rssdp.Infrastructure
private void WriteTrace(string text)
{
- if (LogFunction is not null)
- {
- LogFunction(text);
- }
+ LogFunction?.Invoke(text);
// System.Diagnostics.Debug.WriteLine(text, "SSDP Publisher");
}