aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Networking
diff options
context:
space:
mode:
authorErwin de Haan <EraYaN@users.noreply.github.com>2019-01-13 21:46:33 +0100
committerErwin de Haan <EraYaN@users.noreply.github.com>2019-01-13 21:46:33 +0100
commite8674464373c3635243953cded42fcd2aa87d196 (patch)
tree8087e1c5d47a525b04f3ae7e99183f68391bb410 /Emby.Server.Implementations/Networking
parent65bd052f3e8682d177520af57db1c8ef5cb33262 (diff)
ReSharper format: conform inline 'out' parameters.
Diffstat (limited to 'Emby.Server.Implementations/Networking')
-rw-r--r--Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs39
-rw-r--r--Emby.Server.Implementations/Networking/NetworkManager.cs20
2 files changed, 19 insertions, 40 deletions
diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs
index 21feaea33..16f39daf7 100644
--- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs
+++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs
@@ -524,8 +524,7 @@ namespace System.Net
}
var uintIpAddress = IPNetwork.ToBigInteger(ipaddress);
- byte? cidr2 = null;
- bool parsed = IPNetwork.TryToCidr(netmask, out cidr2);
+ bool parsed = IPNetwork.TryToCidr(netmask, out var cidr2);
if (parsed == false)
{
if (tryParse == false)
@@ -615,8 +614,7 @@ namespace System.Net
/// <returns></returns>
public static BigInteger ToBigInteger(IPAddress ipaddress)
{
- BigInteger? uintIpAddress = null;
- IPNetwork.InternalToBigInteger(false, ipaddress, out uintIpAddress);
+ IPNetwork.InternalToBigInteger(false, ipaddress, out var uintIpAddress);
return (BigInteger)uintIpAddress;
}
@@ -630,8 +628,7 @@ namespace System.Net
/// <returns></returns>
public static bool TryToBigInteger(IPAddress ipaddress, out BigInteger? uintIpAddress)
{
- BigInteger? uintIpAddress2 = null;
- IPNetwork.InternalToBigInteger(true, ipaddress, out uintIpAddress2);
+ IPNetwork.InternalToBigInteger(true, ipaddress, out var uintIpAddress2);
bool parsed = (uintIpAddress2 != null);
uintIpAddress = uintIpAddress2;
return parsed;
@@ -681,9 +678,7 @@ namespace System.Net
/// <returns></returns>
public static BigInteger ToUint(byte cidr, AddressFamily family)
{
-
- BigInteger? uintNetmask = null;
- IPNetwork.InternalToBigInteger(false, cidr, family, out uintNetmask);
+ IPNetwork.InternalToBigInteger(false, cidr, family, out var uintNetmask);
return (BigInteger)uintNetmask;
}
@@ -695,9 +690,7 @@ namespace System.Net
/// <returns></returns>
public static bool TryToUint(byte cidr, AddressFamily family, out BigInteger? uintNetmask)
{
-
- BigInteger? uintNetmask2 = null;
- IPNetwork.InternalToBigInteger(true, cidr, family, out uintNetmask2);
+ IPNetwork.InternalToBigInteger(true, cidr, family, out var uintNetmask2);
bool parsed = (uintNetmask2 != null);
uintNetmask = uintNetmask2;
return parsed;
@@ -812,8 +805,7 @@ namespace System.Net
/// <returns></returns>
public static byte ToCidr(IPAddress netmask)
{
- byte? cidr = null;
- IPNetwork.InternalToCidr(false, netmask, out cidr);
+ IPNetwork.InternalToCidr(false, netmask, out var cidr);
return (byte)cidr;
}
@@ -827,8 +819,7 @@ namespace System.Net
/// <returns></returns>
public static bool TryToCidr(IPAddress netmask, out byte? cidr)
{
- byte? cidr2 = null;
- IPNetwork.InternalToCidr(true, netmask, out cidr2);
+ IPNetwork.InternalToCidr(true, netmask, out var cidr2);
bool parsed = (cidr2 != null);
cidr = cidr2;
return parsed;
@@ -846,8 +837,8 @@ namespace System.Net
cidr = null;
return;
}
- BigInteger? uintNetmask2 = null;
- bool parsed = IPNetwork.TryToBigInteger(netmask, out uintNetmask2);
+
+ bool parsed = IPNetwork.TryToBigInteger(netmask, out var uintNetmask2);
/// 20180217 lduchosal
/// impossible to reach code.
@@ -860,8 +851,7 @@ namespace System.Net
/// }
var uintNetmask = (BigInteger)uintNetmask2;
- byte? cidr2 = null;
- IPNetwork.InternalToCidr(tryParse, uintNetmask, netmask.AddressFamily, out cidr2);
+ IPNetwork.InternalToCidr(tryParse, uintNetmask, netmask.AddressFamily, out var cidr2);
cidr = cidr2;
return;
@@ -1491,8 +1481,7 @@ namespace System.Net
/// <returns></returns>
public static IPNetwork[] Supernet(IPNetwork[] ipnetworks)
{
- IPNetwork[] supernet;
- InternalSupernet(false, ipnetworks, out supernet);
+ InternalSupernet(false, ipnetworks, out var supernet);
return supernet;
}
@@ -1642,14 +1631,12 @@ namespace System.Net
throw new ArgumentNullException(nameof(end));
}
- IPAddress startIP;
- if (!IPAddress.TryParse(start, out startIP))
+ if (!IPAddress.TryParse(start, out var startIP))
{
throw new ArgumentException("start");
}
- IPAddress endIP;
- if (!IPAddress.TryParse(end, out endIP))
+ if (!IPAddress.TryParse(end, out var endIP))
{
throw new ArgumentException("end");
}
diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs
index 70d8376a9..b486c0ef7 100644
--- a/Emby.Server.Implementations/Networking/NetworkManager.cs
+++ b/Emby.Server.Implementations/Networking/NetworkManager.cs
@@ -203,11 +203,9 @@ namespace Emby.Server.Implementations.Networking
private Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
private List<string> GetSubnets(string endpointFirstPart)
{
- List<string> subnets;
-
lock (_subnetLookup)
{
- if (_subnetLookup.TryGetValue(endpointFirstPart, out subnets))
+ if (_subnetLookup.TryGetValue(endpointFirstPart, out var subnets))
{
return subnets;
}
@@ -298,8 +296,7 @@ namespace Emby.Server.Implementations.Networking
throw new ArgumentNullException(nameof(endpoint));
}
- IPAddress address;
- if (IPAddress.TryParse(endpoint, out address))
+ if (IPAddress.TryParse(endpoint, out var address))
{
var addressString = address.ToString();
@@ -348,8 +345,7 @@ namespace Emby.Server.Implementations.Networking
}
else if (resolveHost)
{
- Uri uri;
- if (Uri.TryCreate(endpoint, UriKind.RelativeOrAbsolute, out uri))
+ if (Uri.TryCreate(endpoint, UriKind.RelativeOrAbsolute, out var uri))
{
try
{
@@ -588,9 +584,7 @@ namespace Emby.Server.Implementations.Networking
/// <exception cref="FormatException"></exception>
private static int GetPort(string p)
{
- int port;
-
- if (!int.TryParse(p, out port)
+ if (!int.TryParse(p, out var port)
|| port < IPEndPoint.MinPort
|| port > IPEndPoint.MaxPort)
{
@@ -618,8 +612,7 @@ namespace Emby.Server.Implementations.Networking
public IpAddressInfo ParseIpAddress(string ipAddress)
{
- IpAddressInfo info;
- if (TryParseIpAddress(ipAddress, out info))
+ if (TryParseIpAddress(ipAddress, out var info))
{
return info;
}
@@ -629,8 +622,7 @@ namespace Emby.Server.Implementations.Networking
public bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo)
{
- IPAddress address;
- if (IPAddress.TryParse(ipAddress, out address))
+ if (IPAddress.TryParse(ipAddress, out var address))
{
ipAddressInfo = ToIpAddressInfo(address);
return true;