diff options
Diffstat (limited to 'Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs')
| -rw-r--r-- | Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs index 35cff88dc..7d3106624 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Numerics; @@ -11,22 +11,12 @@ namespace System.Net private byte _cidrSubnet; private IPNetwork _ipnetwork; - private byte _cidr - { - get { return this._ipnetwork.Cidr; } - } - private BigInteger _broadcast - { - get { return IPNetwork.ToBigInteger(this._ipnetwork.Broadcast); } - } - private BigInteger _lastUsable - { - get { return IPNetwork.ToBigInteger(this._ipnetwork.LastUsable); } - } - private BigInteger _network - { - get { return IPNetwork.ToBigInteger(this._ipnetwork.Network); } - } + private byte _cidr => this._ipnetwork.Cidr; + + private BigInteger _broadcast => IPNetwork.ToBigInteger(this._ipnetwork.Broadcast); + + private BigInteger _lastUsable => IPNetwork.ToBigInteger(this._ipnetwork.LastUsable); + private BigInteger _network => IPNetwork.ToBigInteger(this._ipnetwork.Network); #if TRAVISCI public #else @@ -38,7 +28,7 @@ namespace System.Net int maxCidr = ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetwork ? 32 : 128; if (cidrSubnet > maxCidr) { - throw new ArgumentOutOfRangeException("cidrSubnet"); + throw new ArgumentOutOfRangeException(nameof(cidrSubnet)); } if (cidrSubnet < ipnetwork.Cidr) @@ -57,7 +47,7 @@ namespace System.Net { get { - BigInteger count = BigInteger.Pow(2, this._cidrSubnet - this._cidr); + var count = BigInteger.Pow(2, this._cidrSubnet - this._cidr); return count; } } @@ -68,14 +58,14 @@ namespace System.Net { if (i >= this.Count) { - throw new ArgumentOutOfRangeException("i"); + throw new ArgumentOutOfRangeException(nameof(i)); } - BigInteger last = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetworkV6 + var last = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetworkV6 ? this._lastUsable : this._broadcast; - BigInteger increment = (last - this._network) / this.Count; - BigInteger uintNetwork = this._network + ((increment + 1) * i); - IPNetwork ipn = new IPNetwork(uintNetwork, this._ipnetwork.AddressFamily, this._cidrSubnet); + var increment = (last - this._network) / this.Count; + var uintNetwork = this._network + ((increment + 1) * i); + var ipn = new IPNetwork(uintNetwork, this._ipnetwork.AddressFamily, this._cidrSubnet); return ipn; } } @@ -96,10 +86,7 @@ namespace System.Net #region IEnumerator<IPNetwork> Members - public IPNetwork Current - { - get { return this[this._enumerator]; } - } + public IPNetwork Current => this[this._enumerator]; #endregion @@ -115,10 +102,7 @@ namespace System.Net #region IEnumerator Members - object IEnumerator.Current - { - get { return this.Current; } - } + object IEnumerator.Current => this.Current; public bool MoveNext() { @@ -141,4 +125,4 @@ namespace System.Net #endregion } -}
\ No newline at end of file +} |
