diff options
Diffstat (limited to 'Emby.Server.Implementations/Net')
| -rw-r--r-- | Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs | 8 | ||||
| -rw-r--r-- | Emby.Server.Implementations/Net/SocketFactory.cs | 46 | ||||
| -rw-r--r-- | Emby.Server.Implementations/Net/UdpSocket.cs | 9 |
3 files changed, 27 insertions, 36 deletions
diff --git a/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs b/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs index b721e8a26..9d880b0c9 100644 --- a/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs +++ b/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Emby.Server.Implementations.Net { @@ -16,15 +16,17 @@ namespace Emby.Server.Implementations.Net /// <param name="disposing">True if managed objects should be disposed, if false, only unmanaged resources should be released.</param> protected abstract void Dispose(bool disposing); + + //TODO Remove and reimplement using the IsDisposed property directly. /// <summary> - /// Throws and <see cref="System.ObjectDisposedException"/> if the <see cref="IsDisposed"/> property is true. + /// Throws an <see cref="System.ObjectDisposedException"/> if the <see cref="IsDisposed"/> property is true. /// </summary> /// <seealso cref="IsDisposed"/> /// <exception cref="System.ObjectDisposedException">Thrown if the <see cref="IsDisposed"/> property is true.</exception> /// <seealso cref="Dispose()"/> protected virtual void ThrowIfDisposed() { - if (this.IsDisposed) throw new ObjectDisposedException(this.GetType().FullName); + if (IsDisposed) throw new ObjectDisposedException(GetType().Name); } #endregion diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs index 515f99f3c..51d08bd6f 100644 --- a/Emby.Server.Implementations/Net/SocketFactory.cs +++ b/Emby.Server.Implementations/Net/SocketFactory.cs @@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.Net { if (logger == null) { - throw new ArgumentNullException("logger"); + throw new ArgumentNullException(nameof(logger)); } _logger = logger; @@ -31,7 +31,7 @@ namespace Emby.Server.Implementations.Net public ISocket CreateTcpSocket(IpAddressInfo remoteAddress, int remotePort) { - if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", "remotePort"); + if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", nameof(remotePort)); var addressFamily = remoteAddress.AddressFamily == IpAddressFamily.InterNetwork ? AddressFamily.InterNetwork @@ -67,7 +67,7 @@ namespace Emby.Server.Implementations.Net /// <param name="localPort">An integer specifying the local port to bind the acceptSocket to.</param> public ISocket CreateUdpSocket(int localPort) { - if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort"); + if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort)); var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp); try @@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.Net public ISocket CreateUdpBroadcastSocket(int localPort) { - if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort"); + if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort)); var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp); try @@ -111,7 +111,7 @@ namespace Emby.Server.Implementations.Net /// <returns>An implementation of the <see cref="ISocket"/> interface used by RSSDP components to perform acceptSocket operations.</returns> public ISocket CreateSsdpUdpSocket(IpAddressInfo localIpAddress, int localPort) { - if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort"); + if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort)); var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp); try @@ -142,10 +142,10 @@ namespace Emby.Server.Implementations.Net /// <returns></returns> public ISocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort) { - if (ipAddress == null) throw new ArgumentNullException("ipAddress"); - if (ipAddress.Length == 0) throw new ArgumentException("ipAddress cannot be an empty string.", "ipAddress"); - if (multicastTimeToLive <= 0) throw new ArgumentException("multicastTimeToLive cannot be zero or less.", "multicastTimeToLive"); - if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort"); + if (ipAddress == null) throw new ArgumentNullException(nameof(ipAddress)); + if (ipAddress.Length == 0) throw new ArgumentException("ipAddress cannot be an empty string.", nameof(ipAddress)); + if (multicastTimeToLive <= 0) throw new ArgumentException("multicastTimeToLive cannot be zero or less.", nameof(multicastTimeToLive)); + if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort)); var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp); @@ -212,26 +212,18 @@ namespace Emby.Server.Implementations.Net { } - public override bool CanRead - { - get { return true; } - } - public override bool CanSeek - { - get { return false; } - } - public override bool CanWrite - { - get { return true; } - } - public override long Length - { - get { throw new NotImplementedException(); } - } + public override bool CanRead => true; + + public override bool CanSeek => false; + + public override bool CanWrite => true; + + public override long Length => throw new NotImplementedException(); + public override long Position { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } + get => throw new NotImplementedException(); + set => throw new NotImplementedException(); } public override void Write(byte[] buffer, int offset, int count) diff --git a/Emby.Server.Implementations/Net/UdpSocket.cs b/Emby.Server.Implementations/Net/UdpSocket.cs index 8d5b671f2..39f25e024 100644 --- a/Emby.Server.Implementations/Net/UdpSocket.cs +++ b/Emby.Server.Implementations/Net/UdpSocket.cs @@ -16,10 +16,7 @@ namespace Emby.Server.Implementations.Net private Socket _Socket; private int _LocalPort; - public Socket Socket - { - get { return _Socket; } - } + public Socket Socket => _Socket; private readonly SocketAsyncEventArgs _receiveSocketAsyncEventArgs = new SocketAsyncEventArgs() { @@ -36,7 +33,7 @@ namespace Emby.Server.Implementations.Net public UdpSocket(Socket socket, int localPort, IPAddress ip) { - if (socket == null) throw new ArgumentNullException("socket"); + if (socket == null) throw new ArgumentNullException(nameof(socket)); _Socket = socket; _LocalPort = localPort; @@ -102,7 +99,7 @@ namespace Emby.Server.Implementations.Net public UdpSocket(Socket socket, IpEndPointInfo endPoint) { - if (socket == null) throw new ArgumentNullException("socket"); + if (socket == null) throw new ArgumentNullException(nameof(socket)); _Socket = socket; _Socket.Connect(NetworkManager.ToIPEndPoint(endPoint)); |
