Merge branch 'master' into network-rewrite

This commit is contained in:
Shadowghost
2023-05-09 15:25:41 +02:00
154 changed files with 1724 additions and 1078 deletions

View File

@@ -221,10 +221,8 @@ namespace Rssdp.Infrastructure
{
return trimmedSegment.Substring(1, trimmedSegment.Length - 2);
}
else
{
return trimmedSegment;
}
return trimmedSegment;
}
}
}

View File

@@ -64,8 +64,7 @@ namespace Rssdp.Infrastructure
}
message.Method = new HttpMethod(parts[0].Trim());
Uri requestUri;
if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))
if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out var requestUri))
{
message.RequestUri = requestUri;
}

View File

@@ -77,8 +77,7 @@ namespace Rssdp.Infrastructure
message.Version = ParseHttpVersion(parts[0].Trim());
int statusCode = -1;
if (!Int32.TryParse(parts[1].Trim(), out statusCode))
if (!Int32.TryParse(parts[1].Trim(), out var statusCode))
{
throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));
}

View File

@@ -171,10 +171,8 @@ namespace Rssdp
{
return "uuid:" + this.Uuid;
}
else
{
return _Udn;
}
return _Udn;
}
set

View File

@@ -489,8 +489,7 @@ namespace Rssdp.Infrastructure
}
}
Uri retVal;
Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out retVal);
Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out var retVal);
return retVal;
}
@@ -507,8 +506,7 @@ namespace Rssdp.Infrastructure
}
}
Uri retVal;
Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out retVal);
Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out var retVal);
return retVal;
}
@@ -593,10 +591,8 @@ namespace Rssdp.Infrastructure
{
return OneSecond;
}
else
{
return searchWaitTime.Subtract(OneSecond);
}
return searchWaitTime.Subtract(OneSecond);
}
private DiscoveredSsdpDevice FindExistingDeviceNotification(IEnumerable<DiscoveredSsdpDevice> devices, string notificationType, string usn)

View File

@@ -223,7 +223,6 @@ namespace Rssdp.Infrastructure
// Wait on random interval up to MX, as per SSDP spec.
// Also, as per UPnP 1.1/SSDP spec ignore missing/bank MX header. If over 120, assume random value between 0 and 120.
// Using 16 as minimum as that's often the minimum system clock frequency anyway.
int maxWaitInterval = 0;
if (String.IsNullOrEmpty(mx))
{
// Windows Explorer is poorly behaved and doesn't supply an MX header value.
@@ -233,7 +232,7 @@ namespace Rssdp.Infrastructure
// return;
}
if (!Int32.TryParse(mx, out maxWaitInterval) || maxWaitInterval <= 0)
if (!Int32.TryParse(mx, out var maxWaitInterval) || maxWaitInterval <= 0)
{
return;
}
@@ -546,17 +545,14 @@ namespace Rssdp.Infrastructure
{
return nonzeroCacheLifetimesQuery.Min();
}
else
{
return TimeSpan.Zero;
}
return TimeSpan.Zero;
}
private string GetFirstHeaderValue(System.Net.Http.Headers.HttpRequestHeaders httpRequestHeaders, string headerName)
{
string retVal = null;
IEnumerable<String> values = null;
if (httpRequestHeaders.TryGetValues(headerName, out values) && values is not null)
if (httpRequestHeaders.TryGetValues(headerName, out var values) && values is not null)
{
retVal = values.FirstOrDefault();
}
@@ -618,7 +614,7 @@ namespace Rssdp.Infrastructure
public string Key
{
get { return this.SearchTarget + ":" + this.EndPoint.ToString(); }
get { return this.SearchTarget + ":" + this.EndPoint; }
}
public bool IsOld()