From ec1f5dc317182582ebff843c9e8a4d5277405469 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 6 Jan 2019 21:50:43 +0100 Subject: Mayor code cleanup Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment. --- SocketHttpListener/Ext.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'SocketHttpListener/Ext.cs') diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index 125775180..4404235ba 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -149,7 +149,7 @@ namespace SocketHttpListener internal static string CheckIfValidControlData(this byte[] data, string paramName) { return data.Length > 125 - ? String.Format("'{0}' length must be less.", paramName) + ? string.Format("'{0}' length must be less.", paramName) : null; } @@ -222,7 +222,7 @@ namespace SocketHttpListener internal static bool EqualsWith(this int value, char c, Action action) { if (value < 0 || value > 255) - throw new ArgumentOutOfRangeException("value"); + throw new ArgumentOutOfRangeException(nameof(value)); action(value); return value == c - 0; @@ -248,7 +248,7 @@ namespace SocketHttpListener ? "WebSocket server got an internal error." : code == CloseStatusCode.TlsHandshakeFailure ? "An error has occurred while handshaking." - : String.Empty; + : string.Empty; } internal static string GetNameInternal(this string nameAndValue, string separator) @@ -329,7 +329,7 @@ namespace SocketHttpListener { return value.IsToken() ? value - : String.Format("\"{0}\"", value.Replace("\"", "\\\"")); + : string.Format("\"{0}\"", value.Replace("\"", "\\\"")); } internal static byte[] ReadBytes(this Stream stream, int length) @@ -484,13 +484,13 @@ namespace SocketHttpListener this CompressionMethod method, params string[] parameters) { if (method == CompressionMethod.None) - return String.Empty; + return string.Empty; - var m = String.Format("permessage-{0}", method.ToString().ToLower()); + var m = string.Format("permessage-{0}", method.ToString().ToLower()); if (parameters == null || parameters.Length == 0) return m; - return String.Format("{0}; {1}", m, parameters.ToString("; ")); + return string.Format("{0}; {1}", m, parameters.ToString("; ")); } internal static List ToList(this IEnumerable source) @@ -715,7 +715,7 @@ namespace SocketHttpListener case 507: return "Insufficient Storage"; } - return String.Empty; + return string.Empty; } /// @@ -855,7 +855,7 @@ namespace SocketHttpListener public static byte[] ToHostOrder(this byte[] src, ByteOrder srcOrder) { if (src == null) - throw new ArgumentNullException("src"); + throw new ArgumentNullException(nameof(src)); return src.Length > 1 && !srcOrder.IsHostOrder() ? src.Reverse() @@ -886,14 +886,14 @@ namespace SocketHttpListener public static string ToString(this T[] array, string separator) { if (array == null) - throw new ArgumentNullException("array"); + throw new ArgumentNullException(nameof(array)); var len = array.Length; if (len == 0) - return String.Empty; + return string.Empty; if (separator == null) - separator = String.Empty; + separator = string.Empty; var buff = new StringBuilder(64); (len - 1).Times(i => buff.AppendFormat("{0}{1}", array[i].ToString(), separator)); -- cgit v1.2.3 From 8fd0bc63b94d6afac2912217b6118b7c2d533333 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 13 Jan 2019 20:27:29 +0100 Subject: Visual Studio Reformat: SocketHttpListener --- SocketHttpListener/ByteOrder.cs | 24 +- SocketHttpListener/CloseEventArgs.cs | 149 ++--- SocketHttpListener/CloseStatusCode.cs | 178 +++--- SocketHttpListener/CompressionMethod.cs | 36 +- SocketHttpListener/ErrorEventArgs.cs | 68 +-- SocketHttpListener/Ext.cs | 4 +- SocketHttpListener/Fin.cs | 10 +- SocketHttpListener/HttpBase.cs | 4 - SocketHttpListener/HttpResponse.cs | 8 +- SocketHttpListener/Mask.cs | 10 +- SocketHttpListener/MessageEventArgs.cs | 158 ++--- SocketHttpListener/Net/AuthenticationTypes.cs | 6 +- SocketHttpListener/Net/BoundaryType.cs | 7 +- SocketHttpListener/Net/ChunkStream.cs | 1 - SocketHttpListener/Net/ChunkedInputStream.cs | 2 - SocketHttpListener/Net/CookieHelper.cs | 1 - SocketHttpListener/Net/EntitySendFormat.cs | 7 +- SocketHttpListener/Net/HttpConnection.cs | 8 +- SocketHttpListener/Net/HttpEndPointListener.cs | 10 +- SocketHttpListener/Net/HttpEndPointManager.cs | 5 - SocketHttpListener/Net/HttpKnownHeaderNames.cs | 6 +- SocketHttpListener/Net/HttpListener.cs | 4 +- .../Net/HttpListenerContext.Managed.cs | 4 +- SocketHttpListener/Net/HttpListenerContext.cs | 6 +- .../Net/HttpListenerRequest.Managed.cs | 7 +- SocketHttpListener/Net/HttpListenerRequest.cs | 10 +- .../Net/HttpListenerRequestUriBuilder.cs | 2 +- .../Net/HttpListenerResponse.Managed.cs | 5 +- SocketHttpListener/Net/HttpListenerResponse.cs | 7 - .../Net/HttpRequestStream.Managed.cs | 4 - SocketHttpListener/Net/HttpRequestStream.cs | 2 - .../Net/HttpResponseStream.Managed.cs | 4 +- SocketHttpListener/Net/HttpResponseStream.cs | 2 - SocketHttpListener/Net/HttpStatusCode.cs | 634 ++++++++++----------- SocketHttpListener/Net/HttpStatusDescription.cs | 7 +- SocketHttpListener/Net/ListenerPrefix.cs | 1 - SocketHttpListener/Net/UriScheme.cs | 6 +- SocketHttpListener/Net/WebHeaderCollection.cs | 5 - SocketHttpListener/Net/WebHeaderEncoding.cs | 5 +- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 6 - .../Net/WebSockets/HttpWebSocket.Managed.cs | 2 - SocketHttpListener/Net/WebSockets/HttpWebSocket.cs | 3 +- .../Net/WebSockets/WebSocketCloseStatus.cs | 6 +- .../Net/WebSockets/WebSocketContext.cs | 2 - .../Net/WebSockets/WebSocketValidate.cs | 4 +- SocketHttpListener/Opcode.cs | 76 +-- SocketHttpListener/PayloadData.cs | 256 +++++---- SocketHttpListener/Primitives/ITextEncoding.cs | 5 +- SocketHttpListener/Rsv.cs | 10 +- SocketHttpListener/SocketStream.cs | 4 - SocketHttpListener/WebSocket.cs | 5 +- SocketHttpListener/WebSocketException.cs | 105 ++-- SocketHttpListener/WebSocketFrame.cs | 1 - 53 files changed, 903 insertions(+), 999 deletions(-) (limited to 'SocketHttpListener/Ext.cs') diff --git a/SocketHttpListener/ByteOrder.cs b/SocketHttpListener/ByteOrder.cs index f5db52fd7..c04150c74 100644 --- a/SocketHttpListener/ByteOrder.cs +++ b/SocketHttpListener/ByteOrder.cs @@ -1,17 +1,17 @@ namespace SocketHttpListener { - /// - /// Contains the values that indicate whether the byte order is a Little-endian or Big-endian. - /// - public enum ByteOrder : byte - { /// - /// Indicates a Little-endian. + /// Contains the values that indicate whether the byte order is a Little-endian or Big-endian. /// - Little, - /// - /// Indicates a Big-endian. - /// - Big - } + public enum ByteOrder : byte + { + /// + /// Indicates a Little-endian. + /// + Little, + /// + /// Indicates a Big-endian. + /// + Big + } } diff --git a/SocketHttpListener/CloseEventArgs.cs b/SocketHttpListener/CloseEventArgs.cs index ff30126bc..12a24bb4a 100644 --- a/SocketHttpListener/CloseEventArgs.cs +++ b/SocketHttpListener/CloseEventArgs.cs @@ -3,88 +3,95 @@ using System.Text; namespace SocketHttpListener { - /// - /// Contains the event data associated with a event. - /// - /// - /// A event occurs when the WebSocket connection has been closed. - /// If you would like to get the reason for the close, you should access the or - /// property. - /// - public class CloseEventArgs : EventArgs - { - #region Private Fields + /// + /// Contains the event data associated with a event. + /// + /// + /// A event occurs when the WebSocket connection has been closed. + /// If you would like to get the reason for the close, you should access the or + /// property. + /// + public class CloseEventArgs : EventArgs + { + #region Private Fields - private bool _clean; - private ushort _code; - private string _reason; + private bool _clean; + private ushort _code; + private string _reason; - #endregion + #endregion - #region Internal Constructors + #region Internal Constructors - internal CloseEventArgs (PayloadData payload) - { - var data = payload.ApplicationData; - var len = data.Length; - _code = len > 1 - ? data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) - : (ushort) CloseStatusCode.NoStatusCode; + internal CloseEventArgs(PayloadData payload) + { + var data = payload.ApplicationData; + var len = data.Length; + _code = len > 1 + ? data.SubArray(0, 2).ToUInt16(ByteOrder.Big) + : (ushort)CloseStatusCode.NoStatusCode; - _reason = len > 2 - ? GetUtf8String(data.SubArray (2, len - 2)) - : string.Empty; - } + _reason = len > 2 + ? GetUtf8String(data.SubArray(2, len - 2)) + : string.Empty; + } - private static string GetUtf8String(byte[] bytes) - { - return Encoding.UTF8.GetString(bytes, 0, bytes.Length); - } + private static string GetUtf8String(byte[] bytes) + { + return Encoding.UTF8.GetString(bytes, 0, bytes.Length); + } - #endregion + #endregion - #region Public Properties + #region Public Properties - /// - /// Gets the status code for the close. - /// - /// - /// A that represents the status code for the close if any. - /// - public ushort Code { - get { - return _code; - } - } + /// + /// Gets the status code for the close. + /// + /// + /// A that represents the status code for the close if any. + /// + public ushort Code + { + get + { + return _code; + } + } - /// - /// Gets the reason for the close. - /// - /// - /// A that represents the reason for the close if any. - /// - public string Reason { - get { - return _reason; - } - } + /// + /// Gets the reason for the close. + /// + /// + /// A that represents the reason for the close if any. + /// + public string Reason + { + get + { + return _reason; + } + } - /// - /// Gets a value indicating whether the WebSocket connection has been closed cleanly. - /// - /// - /// true if the WebSocket connection has been closed cleanly; otherwise, false. - /// - public bool WasClean { - get { - return _clean; - } + /// + /// Gets a value indicating whether the WebSocket connection has been closed cleanly. + /// + /// + /// true if the WebSocket connection has been closed cleanly; otherwise, false. + /// + public bool WasClean + { + get + { + return _clean; + } - internal set { - _clean = value; - } - } + internal set + { + _clean = value; + } + } - #endregion - } + #endregion + } } diff --git a/SocketHttpListener/CloseStatusCode.cs b/SocketHttpListener/CloseStatusCode.cs index 62a268bce..428595bb0 100644 --- a/SocketHttpListener/CloseStatusCode.cs +++ b/SocketHttpListener/CloseStatusCode.cs @@ -1,94 +1,94 @@ namespace SocketHttpListener { - /// - /// Contains the values of the status code for the WebSocket connection close. - /// - /// - /// - /// The values of the status code are defined in - /// Section 7.4 - /// of RFC 6455. - /// - /// - /// "Reserved value" must not be set as a status code in a close control frame - /// by an endpoint. It's designated for use in applications expecting a status - /// code to indicate that the connection was closed due to the system grounds. - /// - /// - public enum CloseStatusCode : ushort - { /// - /// Equivalent to close status 1000. - /// Indicates a normal close. + /// Contains the values of the status code for the WebSocket connection close. /// - Normal = 1000, - /// - /// Equivalent to close status 1001. - /// Indicates that an endpoint is going away. - /// - Away = 1001, - /// - /// Equivalent to close status 1002. - /// Indicates that an endpoint is terminating the connection due to a protocol error. - /// - ProtocolError = 1002, - /// - /// Equivalent to close status 1003. - /// Indicates that an endpoint is terminating the connection because it has received - /// an unacceptable type message. - /// - IncorrectData = 1003, - /// - /// Equivalent to close status 1004. - /// Still undefined. Reserved value. - /// - Undefined = 1004, - /// - /// Equivalent to close status 1005. - /// Indicates that no status code was actually present. Reserved value. - /// - NoStatusCode = 1005, - /// - /// Equivalent to close status 1006. - /// Indicates that the connection was closed abnormally. Reserved value. - /// - Abnormal = 1006, - /// - /// Equivalent to close status 1007. - /// Indicates that an endpoint is terminating the connection because it has received - /// a message that contains a data that isn't consistent with the type of the message. - /// - InconsistentData = 1007, - /// - /// Equivalent to close status 1008. - /// Indicates that an endpoint is terminating the connection because it has received - /// a message that violates its policy. - /// - PolicyViolation = 1008, - /// - /// Equivalent to close status 1009. - /// Indicates that an endpoint is terminating the connection because it has received - /// a message that is too big to process. - /// - TooBig = 1009, - /// - /// Equivalent to close status 1010. - /// Indicates that the client is terminating the connection because it has expected - /// the server to negotiate one or more extension, but the server didn't return them - /// in the handshake response. - /// - IgnoreExtension = 1010, - /// - /// Equivalent to close status 1011. - /// Indicates that the server is terminating the connection because it has encountered - /// an unexpected condition that prevented it from fulfilling the request. - /// - ServerError = 1011, - /// - /// Equivalent to close status 1015. - /// Indicates that the connection was closed due to a failure to perform a TLS handshake. - /// Reserved value. - /// - TlsHandshakeFailure = 1015 - } + /// + /// + /// The values of the status code are defined in + /// Section 7.4 + /// of RFC 6455. + /// + /// + /// "Reserved value" must not be set as a status code in a close control frame + /// by an endpoint. It's designated for use in applications expecting a status + /// code to indicate that the connection was closed due to the system grounds. + /// + /// + public enum CloseStatusCode : ushort + { + /// + /// Equivalent to close status 1000. + /// Indicates a normal close. + /// + Normal = 1000, + /// + /// Equivalent to close status 1001. + /// Indicates that an endpoint is going away. + /// + Away = 1001, + /// + /// Equivalent to close status 1002. + /// Indicates that an endpoint is terminating the connection due to a protocol error. + /// + ProtocolError = 1002, + /// + /// Equivalent to close status 1003. + /// Indicates that an endpoint is terminating the connection because it has received + /// an unacceptable type message. + /// + IncorrectData = 1003, + /// + /// Equivalent to close status 1004. + /// Still undefined. Reserved value. + /// + Undefined = 1004, + /// + /// Equivalent to close status 1005. + /// Indicates that no status code was actually present. Reserved value. + /// + NoStatusCode = 1005, + /// + /// Equivalent to close status 1006. + /// Indicates that the connection was closed abnormally. Reserved value. + /// + Abnormal = 1006, + /// + /// Equivalent to close status 1007. + /// Indicates that an endpoint is terminating the connection because it has received + /// a message that contains a data that isn't consistent with the type of the message. + /// + InconsistentData = 1007, + /// + /// Equivalent to close status 1008. + /// Indicates that an endpoint is terminating the connection because it has received + /// a message that violates its policy. + /// + PolicyViolation = 1008, + /// + /// Equivalent to close status 1009. + /// Indicates that an endpoint is terminating the connection because it has received + /// a message that is too big to process. + /// + TooBig = 1009, + /// + /// Equivalent to close status 1010. + /// Indicates that the client is terminating the connection because it has expected + /// the server to negotiate one or more extension, but the server didn't return them + /// in the handshake response. + /// + IgnoreExtension = 1010, + /// + /// Equivalent to close status 1011. + /// Indicates that the server is terminating the connection because it has encountered + /// an unexpected condition that prevented it from fulfilling the request. + /// + ServerError = 1011, + /// + /// Equivalent to close status 1015. + /// Indicates that the connection was closed due to a failure to perform a TLS handshake. + /// Reserved value. + /// + TlsHandshakeFailure = 1015 + } } diff --git a/SocketHttpListener/CompressionMethod.cs b/SocketHttpListener/CompressionMethod.cs index 36a48d94c..d6bcd63d8 100644 --- a/SocketHttpListener/CompressionMethod.cs +++ b/SocketHttpListener/CompressionMethod.cs @@ -1,23 +1,23 @@ namespace SocketHttpListener { - /// - /// Contains the values of the compression method used to compress the message on the WebSocket - /// connection. - /// - /// - /// The values of the compression method are defined in - /// Compression - /// Extensions for WebSocket. - /// - public enum CompressionMethod : byte - { /// - /// Indicates non compression. + /// Contains the values of the compression method used to compress the message on the WebSocket + /// connection. /// - None, - /// - /// Indicates using DEFLATE. - /// - Deflate - } + /// + /// The values of the compression method are defined in + /// Compression + /// Extensions for WebSocket. + /// + public enum CompressionMethod : byte + { + /// + /// Indicates non compression. + /// + None, + /// + /// Indicates using DEFLATE. + /// + Deflate + } } diff --git a/SocketHttpListener/ErrorEventArgs.cs b/SocketHttpListener/ErrorEventArgs.cs index bf1d6fc95..6a85feb9c 100644 --- a/SocketHttpListener/ErrorEventArgs.cs +++ b/SocketHttpListener/ErrorEventArgs.cs @@ -2,45 +2,47 @@ using System; namespace SocketHttpListener { - /// - /// Contains the event data associated with a event. - /// - /// - /// A event occurs when the gets an error. - /// If you would like to get the error message, you should access the - /// property. - /// - public class ErrorEventArgs : EventArgs - { - #region Private Fields + /// + /// Contains the event data associated with a event. + /// + /// + /// A event occurs when the gets an error. + /// If you would like to get the error message, you should access the + /// property. + /// + public class ErrorEventArgs : EventArgs + { + #region Private Fields - private string _message; + private string _message; - #endregion + #endregion - #region Internal Constructors + #region Internal Constructors - internal ErrorEventArgs (string message) - { - _message = message; - } + internal ErrorEventArgs(string message) + { + _message = message; + } - #endregion + #endregion - #region Public Properties + #region Public Properties - /// - /// Gets the error message. - /// - /// - /// A that represents the error message. - /// - public string Message { - get { - return _message; - } - } + /// + /// Gets the error message. + /// + /// + /// A that represents the error message. + /// + public string Message + { + get + { + return _message; + } + } - #endregion - } + #endregion + } } diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index 4404235ba..4a92f1c7d 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; using System.IO; using System.IO.Compression; using System.Net; @@ -441,7 +440,8 @@ namespace SocketHttpListener continue; } } - else { + else + { } buffer.Append(c); diff --git a/SocketHttpListener/Fin.cs b/SocketHttpListener/Fin.cs index f91401b99..c8ffbf2b2 100644 --- a/SocketHttpListener/Fin.cs +++ b/SocketHttpListener/Fin.cs @@ -1,8 +1,8 @@ namespace SocketHttpListener { - internal enum Fin : byte - { - More = 0x0, - Final = 0x1 - } + internal enum Fin : byte + { + More = 0x0, + Final = 0x1 + } } diff --git a/SocketHttpListener/HttpBase.cs b/SocketHttpListener/HttpBase.cs index d4ae857ff..4dffe3223 100644 --- a/SocketHttpListener/HttpBase.cs +++ b/SocketHttpListener/HttpBase.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.IO; using System.Text; -using System.Threading; using MediaBrowser.Model.Services; namespace SocketHttpListener diff --git a/SocketHttpListener/HttpResponse.cs b/SocketHttpListener/HttpResponse.cs index 535fde031..24befccb3 100644 --- a/SocketHttpListener/HttpResponse.cs +++ b/SocketHttpListener/HttpResponse.cs @@ -1,13 +1,11 @@ using System; -using System.Collections.Specialized; -using System.IO; +using System.Linq; using System.Net; using System.Text; -using HttpStatusCode = SocketHttpListener.Net.HttpStatusCode; -using HttpVersion = SocketHttpListener.Net.HttpVersion; -using System.Linq; using MediaBrowser.Model.Services; using SocketHttpListener.Net; +using HttpStatusCode = SocketHttpListener.Net.HttpStatusCode; +using HttpVersion = SocketHttpListener.Net.HttpVersion; namespace SocketHttpListener { diff --git a/SocketHttpListener/Mask.cs b/SocketHttpListener/Mask.cs index adc2f098e..c56f5b08c 100644 --- a/SocketHttpListener/Mask.cs +++ b/SocketHttpListener/Mask.cs @@ -1,8 +1,8 @@ namespace SocketHttpListener { - internal enum Mask : byte - { - Unmask = 0x0, - Mask = 0x1 - } + internal enum Mask : byte + { + Unmask = 0x0, + Mask = 0x1 + } } diff --git a/SocketHttpListener/MessageEventArgs.cs b/SocketHttpListener/MessageEventArgs.cs index 86614c43c..5ee4099b8 100644 --- a/SocketHttpListener/MessageEventArgs.cs +++ b/SocketHttpListener/MessageEventArgs.cs @@ -3,94 +3,100 @@ using System.Text; namespace SocketHttpListener { - /// - /// Contains the event data associated with a event. - /// - /// - /// A event occurs when the receives - /// a text or binary data frame. - /// If you want to get the received data, you access the or - /// property. - /// - public class MessageEventArgs : EventArgs - { - #region Private Fields + /// + /// Contains the event data associated with a event. + /// + /// + /// A event occurs when the receives + /// a text or binary data frame. + /// If you want to get the received data, you access the or + /// property. + /// + public class MessageEventArgs : EventArgs + { + #region Private Fields - private string _data; - private Opcode _opcode; - private byte[] _rawData; + private string _data; + private Opcode _opcode; + private byte[] _rawData; - #endregion + #endregion - #region Internal Constructors + #region Internal Constructors - internal MessageEventArgs (Opcode opcode, byte[] data) - { - _opcode = opcode; - _rawData = data; - _data = convertToString (opcode, data); - } + internal MessageEventArgs(Opcode opcode, byte[] data) + { + _opcode = opcode; + _rawData = data; + _data = convertToString(opcode, data); + } - internal MessageEventArgs (Opcode opcode, PayloadData payload) - { - _opcode = opcode; - _rawData = payload.ApplicationData; - _data = convertToString (opcode, _rawData); - } + internal MessageEventArgs(Opcode opcode, PayloadData payload) + { + _opcode = opcode; + _rawData = payload.ApplicationData; + _data = convertToString(opcode, _rawData); + } - #endregion + #endregion - #region Public Properties + #region Public Properties - /// - /// Gets the received data as a . - /// - /// - /// A that contains the received data. - /// - public string Data { - get { - return _data; - } - } + /// + /// Gets the received data as a . + /// + /// + /// A that contains the received data. + /// + public string Data + { + get + { + return _data; + } + } - /// - /// Gets the received data as an array of . - /// - /// - /// An array of that contains the received data. - /// - public byte [] RawData { - get { - return _rawData; - } - } + /// + /// Gets the received data as an array of . + /// + /// + /// An array of that contains the received data. + /// + public byte[] RawData + { + get + { + return _rawData; + } + } - /// - /// Gets the type of the received data. - /// - /// - /// One of the values, indicates the type of the received data. - /// - public Opcode Type { - get { - return _opcode; - } - } + /// + /// Gets the type of the received data. + /// + /// + /// One of the values, indicates the type of the received data. + /// + public Opcode Type + { + get + { + return _opcode; + } + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private static string convertToString (Opcode opcode, byte [] data) - { - return data.Length == 0 - ? string.Empty - : opcode == Opcode.Text - ? Encoding.UTF8.GetString (data, 0, data.Length) - : opcode.ToString (); - } + private static string convertToString(Opcode opcode, byte[] data) + { + return data.Length == 0 + ? string.Empty + : opcode == Opcode.Text + ? Encoding.UTF8.GetString(data, 0, data.Length) + : opcode.ToString(); + } - #endregion - } + #endregion + } } diff --git a/SocketHttpListener/Net/AuthenticationTypes.cs b/SocketHttpListener/Net/AuthenticationTypes.cs index df6b9d576..991133c29 100644 --- a/SocketHttpListener/Net/AuthenticationTypes.cs +++ b/SocketHttpListener/Net/AuthenticationTypes.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SocketHttpListener.Net +namespace SocketHttpListener.Net { internal class AuthenticationTypes { diff --git a/SocketHttpListener/Net/BoundaryType.cs b/SocketHttpListener/Net/BoundaryType.cs index f1e799f63..8c940c25d 100644 --- a/SocketHttpListener/Net/BoundaryType.cs +++ b/SocketHttpListener/Net/BoundaryType.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; - -namespace SocketHttpListener.Net +namespace SocketHttpListener.Net { internal enum BoundaryType { diff --git a/SocketHttpListener/Net/ChunkStream.cs b/SocketHttpListener/Net/ChunkStream.cs index 5cc01614f..b9b5edb38 100644 --- a/SocketHttpListener/Net/ChunkStream.cs +++ b/SocketHttpListener/Net/ChunkStream.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; diff --git a/SocketHttpListener/Net/ChunkedInputStream.cs b/SocketHttpListener/Net/ChunkedInputStream.cs index 4d6d96a6c..e24218456 100644 --- a/SocketHttpListener/Net/ChunkedInputStream.cs +++ b/SocketHttpListener/Net/ChunkedInputStream.cs @@ -1,8 +1,6 @@ using System; using System.IO; using System.Net; -using System.Runtime.InteropServices; -using SocketHttpListener.Primitives; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/CookieHelper.cs b/SocketHttpListener/Net/CookieHelper.cs index 6c1764e09..32b46fb69 100644 --- a/SocketHttpListener/Net/CookieHelper.cs +++ b/SocketHttpListener/Net/CookieHelper.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.Net; using System.Text; -using System.Threading.Tasks; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/EntitySendFormat.cs b/SocketHttpListener/Net/EntitySendFormat.cs index 9caee3e11..cb3aa424c 100644 --- a/SocketHttpListener/Net/EntitySendFormat.cs +++ b/SocketHttpListener/Net/EntitySendFormat.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; - -namespace SocketHttpListener.Net +namespace SocketHttpListener.Net { internal enum EntitySendFormat { diff --git a/SocketHttpListener/Net/HttpConnection.cs b/SocketHttpListener/Net/HttpConnection.cs index 4fc9a468c..86f9dc635 100644 --- a/SocketHttpListener/Net/HttpConnection.cs +++ b/SocketHttpListener/Net/HttpConnection.cs @@ -3,19 +3,17 @@ using System.IO; using System.Net; using System.Net.Security; using System.Net.Sockets; +using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Text; +using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; -using MediaBrowser.Model.Net; using MediaBrowser.Model.System; using MediaBrowser.Model.Text; +using Microsoft.Extensions.Logging; using SocketHttpListener.Primitives; -using System.Security.Authentication; - -using System.Threading; namespace SocketHttpListener.Net { sealed class HttpConnection diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs index a108e7dd4..ee6ddaa84 100644 --- a/SocketHttpListener/Net/HttpEndPointListener.cs +++ b/SocketHttpListener/Net/HttpEndPointListener.cs @@ -1,21 +1,15 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.IO; using System.Net; using System.Net.Sockets; using System.Security.Cryptography.X509Certificates; using System.Threading; using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Net; using MediaBrowser.Model.System; using MediaBrowser.Model.Text; -using SocketHttpListener.Primitives; -using ProtocolType = MediaBrowser.Model.Net.ProtocolType; -using SocketType = MediaBrowser.Model.Net.SocketType; -using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace SocketHttpListener.Net { @@ -209,7 +203,7 @@ namespace SocketHttpListener.Net return; } - if(accepted == null) + if (accepted == null) { return; } diff --git a/SocketHttpListener/Net/HttpEndPointManager.cs b/SocketHttpListener/Net/HttpEndPointManager.cs index 01b5ae9bd..787730ed4 100644 --- a/SocketHttpListener/Net/HttpEndPointManager.cs +++ b/SocketHttpListener/Net/HttpEndPointManager.cs @@ -3,12 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Net; using System.Net.Sockets; -using System.Reflection; -using System.Threading.Tasks; -using MediaBrowser.Model.IO; using Microsoft.Extensions.Logging; -using MediaBrowser.Model.Net; -using SocketHttpListener.Primitives; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpKnownHeaderNames.cs b/SocketHttpListener/Net/HttpKnownHeaderNames.cs index ea4695850..bef25ab16 100644 --- a/SocketHttpListener/Net/HttpKnownHeaderNames.cs +++ b/SocketHttpListener/Net/HttpKnownHeaderNames.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SocketHttpListener.Net +namespace SocketHttpListener.Net { internal static partial class HttpKnownHeaderNames { diff --git a/SocketHttpListener/Net/HttpListener.cs b/SocketHttpListener/Net/HttpListener.cs index a159cd273..4e2239a1a 100644 --- a/SocketHttpListener/Net/HttpListener.cs +++ b/SocketHttpListener/Net/HttpListener.cs @@ -1,17 +1,15 @@ using System; using System.Collections; using System.Collections.Generic; -using System.IO; using System.Net; using System.Security.Cryptography.X509Certificates; using MediaBrowser.Common.Net; using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Net; using MediaBrowser.Model.System; using MediaBrowser.Model.Text; -using SocketHttpListener.Primitives; +using Microsoft.Extensions.Logging; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpListenerContext.Managed.cs b/SocketHttpListener/Net/HttpListenerContext.Managed.cs index db795f742..a017d0d27 100644 --- a/SocketHttpListener/Net/HttpListenerContext.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerContext.Managed.cs @@ -1,8 +1,8 @@ -using System.ComponentModel; +using System; +using System.ComponentModel; using System.Security.Principal; using System.Text; using System.Threading.Tasks; -using System; using MediaBrowser.Model.Text; using SocketHttpListener.Net.WebSockets; diff --git a/SocketHttpListener/Net/HttpListenerContext.cs b/SocketHttpListener/Net/HttpListenerContext.cs index e3e6eb906..0bb31ef3e 100644 --- a/SocketHttpListener/Net/HttpListenerContext.cs +++ b/SocketHttpListener/Net/HttpListenerContext.cs @@ -1,12 +1,8 @@ using System; using System.Net; using System.Security.Principal; -using MediaBrowser.Model.Cryptography; -using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; -using MediaBrowser.Model.Text; -using SocketHttpListener.Net.WebSockets; using System.Threading.Tasks; +using SocketHttpListener.Net.WebSockets; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpListenerRequest.Managed.cs b/SocketHttpListener/Net/HttpListenerRequest.Managed.cs index 8b68afe33..54bfa36a0 100644 --- a/SocketHttpListener/Net/HttpListenerRequest.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerRequest.Managed.cs @@ -1,12 +1,7 @@ using System; -using System.Text; -using System.Collections.Specialized; -using System.Globalization; using System.IO; -using System.Security.Authentication.ExtendedProtection; -using System.Security.Cryptography.X509Certificates; +using System.Text; using MediaBrowser.Model.Services; -using MediaBrowser.Model.Text; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpListenerRequest.cs b/SocketHttpListener/Net/HttpListenerRequest.cs index 16e245611..2e8396f6f 100644 --- a/SocketHttpListener/Net/HttpListenerRequest.cs +++ b/SocketHttpListener/Net/HttpListenerRequest.cs @@ -1,17 +1,11 @@ using System; -using System.Collections.Specialized; +using System.Collections.Generic; using System.Globalization; -using System.IO; using System.Net; -using System.Security.Cryptography.X509Certificates; using System.Text; -using System.Threading.Tasks; -using MediaBrowser.Model.Net; using MediaBrowser.Model.Services; -using MediaBrowser.Model.Text; -using SocketHttpListener.Primitives; -using System.Collections.Generic; using SocketHttpListener.Net.WebSockets; +using SocketHttpListener.Primitives; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs index 63790d796..ced23d9c2 100644 --- a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs +++ b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Text; using System.Globalization; +using System.Text; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs index 8fb4518a1..ff4437d9e 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs @@ -1,14 +1,13 @@ using System; -using System.Collections.Generic; using System.Globalization; using System.IO; using System.Net; using System.Text; +using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.IO; using MediaBrowser.Model.Text; using SocketHttpListener.Primitives; -using System.Threading; -using MediaBrowser.Model.IO; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpListenerResponse.cs b/SocketHttpListener/Net/HttpListenerResponse.cs index 351a206ee..f9455db72 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.cs @@ -1,14 +1,7 @@ using System; -using System.Collections.Generic; using System.IO; using System.Net; using System.Text; -using System.Threading.Tasks; -using System.Globalization; -using System.Runtime.InteropServices; -using System.ComponentModel; -using System.Diagnostics; -using Microsoft.Win32.SafeHandles; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpRequestStream.Managed.cs b/SocketHttpListener/Net/HttpRequestStream.Managed.cs index 493e2673b..a0b6cba7e 100644 --- a/SocketHttpListener/Net/HttpRequestStream.Managed.cs +++ b/SocketHttpListener/Net/HttpRequestStream.Managed.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Runtime.ExceptionServices; -using System.Text; -using System.Threading.Tasks; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpRequestStream.cs b/SocketHttpListener/Net/HttpRequestStream.cs index c9a1d5a2d..d5cbc86d8 100644 --- a/SocketHttpListener/Net/HttpRequestStream.cs +++ b/SocketHttpListener/Net/HttpRequestStream.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs index 719dfcc12..5fcf08d02 100644 --- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs +++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs @@ -1,15 +1,13 @@ using System; -using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Sockets; -using System.Runtime.ExceptionServices; using System.Text; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.System; +using Microsoft.Extensions.Logging; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/HttpResponseStream.cs b/SocketHttpListener/Net/HttpResponseStream.cs index 5b7fa417f..8ae7f2881 100644 --- a/SocketHttpListener/Net/HttpResponseStream.cs +++ b/SocketHttpListener/Net/HttpResponseStream.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpStatusCode.cs b/SocketHttpListener/Net/HttpStatusCode.cs index 93da82ba0..d4bb61b8a 100644 --- a/SocketHttpListener/Net/HttpStatusCode.cs +++ b/SocketHttpListener/Net/HttpStatusCode.cs @@ -1,321 +1,321 @@ namespace SocketHttpListener.Net { - /// - /// Contains the values of the HTTP status codes. - /// - /// - /// The HttpStatusCode enumeration contains the values of the HTTP status codes defined in - /// RFC 2616 for HTTP 1.1. - /// - public enum HttpStatusCode - { /// - /// Equivalent to status code 100. - /// Indicates that the client should continue with its request. - /// - Continue = 100, - /// - /// Equivalent to status code 101. - /// Indicates that the server is switching the HTTP version or protocol on the connection. - /// - SwitchingProtocols = 101, - /// - /// Equivalent to status code 200. - /// Indicates that the client's request has succeeded. - /// - OK = 200, - /// - /// Equivalent to status code 201. - /// Indicates that the client's request has been fulfilled and resulted in a new resource being - /// created. - /// - Created = 201, - /// - /// Equivalent to status code 202. - /// Indicates that the client's request has been accepted for processing, but the processing - /// hasn't been completed. - /// - Accepted = 202, - /// - /// Equivalent to status code 203. - /// Indicates that the returned metainformation is from a local or a third-party copy instead of - /// the origin server. - /// - NonAuthoritativeInformation = 203, - /// - /// Equivalent to status code 204. - /// Indicates that the server has fulfilled the client's request but doesn't need to return - /// an entity-body. - /// - NoContent = 204, - /// - /// Equivalent to status code 205. - /// Indicates that the server has fulfilled the client's request, and the user agent should - /// reset the document view which caused the request to be sent. - /// - ResetContent = 205, - /// - /// Equivalent to status code 206. - /// Indicates that the server has fulfilled the partial GET request for the resource. - /// - PartialContent = 206, - /// - /// - /// Equivalent to status code 300. - /// Indicates that the requested resource corresponds to any of multiple representations. - /// - /// - /// MultipleChoices is a synonym for Ambiguous. - /// - /// - MultipleChoices = 300, - /// - /// - /// Equivalent to status code 300. - /// Indicates that the requested resource corresponds to any of multiple representations. - /// - /// - /// Ambiguous is a synonym for MultipleChoices. - /// - /// - Ambiguous = 300, - /// - /// - /// Equivalent to status code 301. - /// Indicates that the requested resource has been assigned a new permanent URI and - /// any future references to this resource should use one of the returned URIs. - /// - /// - /// MovedPermanently is a synonym for Moved. - /// - /// - MovedPermanently = 301, - /// - /// - /// Equivalent to status code 301. - /// Indicates that the requested resource has been assigned a new permanent URI and - /// any future references to this resource should use one of the returned URIs. - /// - /// - /// Moved is a synonym for MovedPermanently. - /// - /// - Moved = 301, - /// - /// - /// Equivalent to status code 302. - /// Indicates that the requested resource is located temporarily under a different URI. - /// - /// - /// Found is a synonym for Redirect. - /// - /// - Found = 302, - /// - /// - /// Equivalent to status code 302. - /// Indicates that the requested resource is located temporarily under a different URI. - /// - /// - /// Redirect is a synonym for Found. - /// - /// - Redirect = 302, - /// - /// - /// Equivalent to status code 303. - /// Indicates that the response to the request can be found under a different URI and - /// should be retrieved using a GET method on that resource. - /// - /// - /// SeeOther is a synonym for RedirectMethod. - /// - /// - SeeOther = 303, - /// - /// - /// Equivalent to status code 303. - /// Indicates that the response to the request can be found under a different URI and - /// should be retrieved using a GET method on that resource. - /// - /// - /// RedirectMethod is a synonym for SeeOther. - /// - /// - RedirectMethod = 303, - /// - /// Equivalent to status code 304. - /// Indicates that the client has performed a conditional GET request and access is allowed, - /// but the document hasn't been modified. - /// - NotModified = 304, - /// - /// Equivalent to status code 305. - /// Indicates that the requested resource must be accessed through the proxy given by - /// the Location field. - /// - UseProxy = 305, - /// - /// Equivalent to status code 306. - /// This status code was used in a previous version of the specification, is no longer used, - /// and is reserved for future use. - /// - Unused = 306, - /// - /// - /// Equivalent to status code 307. - /// Indicates that the requested resource is located temporarily under a different URI. - /// - /// - /// TemporaryRedirect is a synonym for RedirectKeepVerb. - /// - /// - TemporaryRedirect = 307, - /// - /// - /// Equivalent to status code 307. - /// Indicates that the requested resource is located temporarily under a different URI. - /// - /// - /// RedirectKeepVerb is a synonym for TemporaryRedirect. - /// - /// - RedirectKeepVerb = 307, - /// - /// Equivalent to status code 400. - /// Indicates that the client's request couldn't be understood by the server due to - /// malformed syntax. - /// - BadRequest = 400, - /// - /// Equivalent to status code 401. - /// Indicates that the client's request requires user authentication. - /// - Unauthorized = 401, - /// - /// Equivalent to status code 402. - /// This status code is reserved for future use. - /// - PaymentRequired = 402, - /// - /// Equivalent to status code 403. - /// Indicates that the server understood the client's request but is refusing to fulfill it. - /// - Forbidden = 403, - /// - /// Equivalent to status code 404. - /// Indicates that the server hasn't found anything matching the request URI. - /// - NotFound = 404, - /// - /// Equivalent to status code 405. - /// Indicates that the method specified in the request line isn't allowed for the resource - /// identified by the request URI. - /// - MethodNotAllowed = 405, - /// - /// Equivalent to status code 406. - /// Indicates that the server doesn't have the appropriate resource to respond to the Accept - /// headers in the client's request. - /// - NotAcceptable = 406, - /// - /// Equivalent to status code 407. - /// Indicates that the client must first authenticate itself with the proxy. - /// - ProxyAuthenticationRequired = 407, - /// - /// Equivalent to status code 408. - /// Indicates that the client didn't produce a request within the time that the server was - /// prepared to wait. - /// - RequestTimeout = 408, - /// - /// Equivalent to status code 409. - /// Indicates that the client's request couldn't be completed due to a conflict on the server. - /// - Conflict = 409, - /// - /// Equivalent to status code 410. - /// Indicates that the requested resource is no longer available at the server and - /// no forwarding address is known. - /// - Gone = 410, - /// - /// Equivalent to status code 411. - /// Indicates that the server refuses to accept the client's request without a defined - /// Content-Length. - /// - LengthRequired = 411, - /// - /// Equivalent to status code 412. - /// Indicates that the precondition given in one or more of the request headers evaluated to - /// false when it was tested on the server. - /// - PreconditionFailed = 412, - /// - /// Equivalent to status code 413. - /// Indicates that the entity of the client's request is larger than the server is willing or - /// able to process. - /// - RequestEntityTooLarge = 413, - /// - /// Equivalent to status code 414. - /// Indicates that the request URI is longer than the server is willing to interpret. - /// - RequestUriTooLong = 414, - /// - /// Equivalent to status code 415. - /// Indicates that the entity of the client's request is in a format not supported by - /// the requested resource for the requested method. - /// - UnsupportedMediaType = 415, - /// - /// Equivalent to status code 416. - /// Indicates that none of the range specifier values in a Range request header overlap - /// the current extent of the selected resource. - /// - RequestedRangeNotSatisfiable = 416, - /// - /// Equivalent to status code 417. - /// Indicates that the expectation given in an Expect request header couldn't be met by - /// the server. - /// - ExpectationFailed = 417, - /// - /// Equivalent to status code 500. - /// Indicates that the server encountered an unexpected condition which prevented it from - /// fulfilling the client's request. - /// - InternalServerError = 500, - /// - /// Equivalent to status code 501. - /// Indicates that the server doesn't support the functionality required to fulfill the client's - /// request. - /// - NotImplemented = 501, - /// - /// Equivalent to status code 502. - /// Indicates that a gateway or proxy server received an invalid response from the upstream - /// server. - /// - BadGateway = 502, - /// - /// Equivalent to status code 503. - /// Indicates that the server is currently unable to handle the client's request due to - /// a temporary overloading or maintenance of the server. - /// - ServiceUnavailable = 503, - /// - /// Equivalent to status code 504. - /// Indicates that a gateway or proxy server didn't receive a timely response from the upstream - /// server or some other auxiliary server. - /// - GatewayTimeout = 504, - /// - /// Equivalent to status code 505. - /// Indicates that the server doesn't support the HTTP version used in the client's request. - /// - HttpVersionNotSupported = 505, - } + /// Contains the values of the HTTP status codes. + /// + /// + /// The HttpStatusCode enumeration contains the values of the HTTP status codes defined in + /// RFC 2616 for HTTP 1.1. + /// + public enum HttpStatusCode + { + /// + /// Equivalent to status code 100. + /// Indicates that the client should continue with its request. + /// + Continue = 100, + /// + /// Equivalent to status code 101. + /// Indicates that the server is switching the HTTP version or protocol on the connection. + /// + SwitchingProtocols = 101, + /// + /// Equivalent to status code 200. + /// Indicates that the client's request has succeeded. + /// + OK = 200, + /// + /// Equivalent to status code 201. + /// Indicates that the client's request has been fulfilled and resulted in a new resource being + /// created. + /// + Created = 201, + /// + /// Equivalent to status code 202. + /// Indicates that the client's request has been accepted for processing, but the processing + /// hasn't been completed. + /// + Accepted = 202, + /// + /// Equivalent to status code 203. + /// Indicates that the returned metainformation is from a local or a third-party copy instead of + /// the origin server. + /// + NonAuthoritativeInformation = 203, + /// + /// Equivalent to status code 204. + /// Indicates that the server has fulfilled the client's request but doesn't need to return + /// an entity-body. + /// + NoContent = 204, + /// + /// Equivalent to status code 205. + /// Indicates that the server has fulfilled the client's request, and the user agent should + /// reset the document view which caused the request to be sent. + /// + ResetContent = 205, + /// + /// Equivalent to status code 206. + /// Indicates that the server has fulfilled the partial GET request for the resource. + /// + PartialContent = 206, + /// + /// + /// Equivalent to status code 300. + /// Indicates that the requested resource corresponds to any of multiple representations. + /// + /// + /// MultipleChoices is a synonym for Ambiguous. + /// + /// + MultipleChoices = 300, + /// + /// + /// Equivalent to status code 300. + /// Indicates that the requested resource corresponds to any of multiple representations. + /// + /// + /// Ambiguous is a synonym for MultipleChoices. + /// + /// + Ambiguous = 300, + /// + /// + /// Equivalent to status code 301. + /// Indicates that the requested resource has been assigned a new permanent URI and + /// any future references to this resource should use one of the returned URIs. + /// + /// + /// MovedPermanently is a synonym for Moved. + /// + /// + MovedPermanently = 301, + /// + /// + /// Equivalent to status code 301. + /// Indicates that the requested resource has been assigned a new permanent URI and + /// any future references to this resource should use one of the returned URIs. + /// + /// + /// Moved is a synonym for MovedPermanently. + /// + /// + Moved = 301, + /// + /// + /// Equivalent to status code 302. + /// Indicates that the requested resource is located temporarily under a different URI. + /// + /// + /// Found is a synonym for Redirect. + /// + /// + Found = 302, + /// + /// + /// Equivalent to status code 302. + /// Indicates that the requested resource is located temporarily under a different URI. + /// + /// + /// Redirect is a synonym for Found. + /// + /// + Redirect = 302, + /// + /// + /// Equivalent to status code 303. + /// Indicates that the response to the request can be found under a different URI and + /// should be retrieved using a GET method on that resource. + /// + /// + /// SeeOther is a synonym for RedirectMethod. + /// + /// + SeeOther = 303, + /// + /// + /// Equivalent to status code 303. + /// Indicates that the response to the request can be found under a different URI and + /// should be retrieved using a GET method on that resource. + /// + /// + /// RedirectMethod is a synonym for SeeOther. + /// + /// + RedirectMethod = 303, + /// + /// Equivalent to status code 304. + /// Indicates that the client has performed a conditional GET request and access is allowed, + /// but the document hasn't been modified. + /// + NotModified = 304, + /// + /// Equivalent to status code 305. + /// Indicates that the requested resource must be accessed through the proxy given by + /// the Location field. + /// + UseProxy = 305, + /// + /// Equivalent to status code 306. + /// This status code was used in a previous version of the specification, is no longer used, + /// and is reserved for future use. + /// + Unused = 306, + /// + /// + /// Equivalent to status code 307. + /// Indicates that the requested resource is located temporarily under a different URI. + /// + /// + /// TemporaryRedirect is a synonym for RedirectKeepVerb. + /// + /// + TemporaryRedirect = 307, + /// + /// + /// Equivalent to status code 307. + /// Indicates that the requested resource is located temporarily under a different URI. + /// + /// + /// RedirectKeepVerb is a synonym for TemporaryRedirect. + /// + /// + RedirectKeepVerb = 307, + /// + /// Equivalent to status code 400. + /// Indicates that the client's request couldn't be understood by the server due to + /// malformed syntax. + /// + BadRequest = 400, + /// + /// Equivalent to status code 401. + /// Indicates that the client's request requires user authentication. + /// + Unauthorized = 401, + /// + /// Equivalent to status code 402. + /// This status code is reserved for future use. + /// + PaymentRequired = 402, + /// + /// Equivalent to status code 403. + /// Indicates that the server understood the client's request but is refusing to fulfill it. + /// + Forbidden = 403, + /// + /// Equivalent to status code 404. + /// Indicates that the server hasn't found anything matching the request URI. + /// + NotFound = 404, + /// + /// Equivalent to status code 405. + /// Indicates that the method specified in the request line isn't allowed for the resource + /// identified by the request URI. + /// + MethodNotAllowed = 405, + /// + /// Equivalent to status code 406. + /// Indicates that the server doesn't have the appropriate resource to respond to the Accept + /// headers in the client's request. + /// + NotAcceptable = 406, + /// + /// Equivalent to status code 407. + /// Indicates that the client must first authenticate itself with the proxy. + /// + ProxyAuthenticationRequired = 407, + /// + /// Equivalent to status code 408. + /// Indicates that the client didn't produce a request within the time that the server was + /// prepared to wait. + /// + RequestTimeout = 408, + /// + /// Equivalent to status code 409. + /// Indicates that the client's request couldn't be completed due to a conflict on the server. + /// + Conflict = 409, + /// + /// Equivalent to status code 410. + /// Indicates that the requested resource is no longer available at the server and + /// no forwarding address is known. + /// + Gone = 410, + /// + /// Equivalent to status code 411. + /// Indicates that the server refuses to accept the client's request without a defined + /// Content-Length. + /// + LengthRequired = 411, + /// + /// Equivalent to status code 412. + /// Indicates that the precondition given in one or more of the request headers evaluated to + /// false when it was tested on the server. + /// + PreconditionFailed = 412, + /// + /// Equivalent to status code 413. + /// Indicates that the entity of the client's request is larger than the server is willing or + /// able to process. + /// + RequestEntityTooLarge = 413, + /// + /// Equivalent to status code 414. + /// Indicates that the request URI is longer than the server is willing to interpret. + /// + RequestUriTooLong = 414, + /// + /// Equivalent to status code 415. + /// Indicates that the entity of the client's request is in a format not supported by + /// the requested resource for the requested method. + /// + UnsupportedMediaType = 415, + /// + /// Equivalent to status code 416. + /// Indicates that none of the range specifier values in a Range request header overlap + /// the current extent of the selected resource. + /// + RequestedRangeNotSatisfiable = 416, + /// + /// Equivalent to status code 417. + /// Indicates that the expectation given in an Expect request header couldn't be met by + /// the server. + /// + ExpectationFailed = 417, + /// + /// Equivalent to status code 500. + /// Indicates that the server encountered an unexpected condition which prevented it from + /// fulfilling the client's request. + /// + InternalServerError = 500, + /// + /// Equivalent to status code 501. + /// Indicates that the server doesn't support the functionality required to fulfill the client's + /// request. + /// + NotImplemented = 501, + /// + /// Equivalent to status code 502. + /// Indicates that a gateway or proxy server received an invalid response from the upstream + /// server. + /// + BadGateway = 502, + /// + /// Equivalent to status code 503. + /// Indicates that the server is currently unable to handle the client's request due to + /// a temporary overloading or maintenance of the server. + /// + ServiceUnavailable = 503, + /// + /// Equivalent to status code 504. + /// Indicates that a gateway or proxy server didn't receive a timely response from the upstream + /// server or some other auxiliary server. + /// + GatewayTimeout = 504, + /// + /// Equivalent to status code 505. + /// Indicates that the server doesn't support the HTTP version used in the client's request. + /// + HttpVersionNotSupported = 505, + } } diff --git a/SocketHttpListener/Net/HttpStatusDescription.cs b/SocketHttpListener/Net/HttpStatusDescription.cs index 9cc4a8e8c..d0587dff7 100644 --- a/SocketHttpListener/Net/HttpStatusDescription.cs +++ b/SocketHttpListener/Net/HttpStatusDescription.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; - -namespace SocketHttpListener.Net +namespace SocketHttpListener.Net { internal static class HttpStatusDescription { diff --git a/SocketHttpListener/Net/ListenerPrefix.cs b/SocketHttpListener/Net/ListenerPrefix.cs index 99bb118e5..b29cc5c6d 100644 --- a/SocketHttpListener/Net/ListenerPrefix.cs +++ b/SocketHttpListener/Net/ListenerPrefix.cs @@ -1,6 +1,5 @@ using System; using System.Net; -using MediaBrowser.Model.Net; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/UriScheme.cs b/SocketHttpListener/Net/UriScheme.cs index 732fc0e7d..0e747154f 100644 --- a/SocketHttpListener/Net/UriScheme.cs +++ b/SocketHttpListener/Net/UriScheme.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SocketHttpListener.Net +namespace SocketHttpListener.Net { internal static class UriScheme { diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs index ed3cb921c..8c3395df5 100644 --- a/SocketHttpListener/Net/WebHeaderCollection.cs +++ b/SocketHttpListener/Net/WebHeaderCollection.cs @@ -1,13 +1,8 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Net; using System.Runtime.InteropServices; -using System.Runtime.Serialization; using System.Text; using MediaBrowser.Model.Services; -using MediaBrowser.Model.Extensions; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/WebHeaderEncoding.cs b/SocketHttpListener/Net/WebHeaderEncoding.cs index 7290bfc63..a269b1eaf 100644 --- a/SocketHttpListener/Net/WebHeaderEncoding.cs +++ b/SocketHttpListener/Net/WebHeaderEncoding.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; +using System.Text; namespace SocketHttpListener.Net { diff --git a/SocketHttpListener/Net/WebSockets/HttpListenerWebSocketContext.cs b/SocketHttpListener/Net/WebSockets/HttpListenerWebSocketContext.cs index 49375678d..5ed49ec47 100644 --- a/SocketHttpListener/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/SocketHttpListener/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -1,14 +1,8 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.IO; using System.Net; using System.Security.Principal; -using MediaBrowser.Model.Cryptography; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Net; using MediaBrowser.Model.Services; -using SocketHttpListener.Primitives; namespace SocketHttpListener.Net.WebSockets { diff --git a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs index 571e4bdba..96b960f7b 100644 --- a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs +++ b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; namespace SocketHttpListener.Net.WebSockets diff --git a/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs b/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs index f72a139f3..4667275c5 100644 --- a/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs +++ b/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs @@ -1,8 +1,7 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; +using System.Text; using System.Threading; namespace SocketHttpListener.Net.WebSockets diff --git a/SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs b/SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs index b83b6cd0f..451b16ec3 100644 --- a/SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs +++ b/SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SocketHttpListener.Net.WebSockets +namespace SocketHttpListener.Net.WebSockets { public enum WebSocketCloseStatus { diff --git a/SocketHttpListener/Net/WebSockets/WebSocketContext.cs b/SocketHttpListener/Net/WebSockets/WebSocketContext.cs index 071b5fe05..10ad86439 100644 --- a/SocketHttpListener/Net/WebSockets/WebSocketContext.cs +++ b/SocketHttpListener/Net/WebSockets/WebSocketContext.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; using System.Net; using System.Security.Principal; -using MediaBrowser.Model.Net; using MediaBrowser.Model.Services; namespace SocketHttpListener.Net.WebSockets diff --git a/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs b/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs index 00895ea01..2f1b428ab 100644 --- a/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs +++ b/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; -using System.Text; -using MediaBrowser.Model.Net; using System.Globalization; +using System.Text; using WebSocketState = System.Net.WebSockets.WebSocketState; namespace SocketHttpListener.Net.WebSockets diff --git a/SocketHttpListener/Opcode.cs b/SocketHttpListener/Opcode.cs index 62b7d8585..69cf3f372 100644 --- a/SocketHttpListener/Opcode.cs +++ b/SocketHttpListener/Opcode.cs @@ -1,43 +1,43 @@ namespace SocketHttpListener { - /// - /// Contains the values of the opcode that indicates the type of a WebSocket frame. - /// - /// - /// The values of the opcode are defined in - /// Section 5.2 of RFC 6455. - /// - public enum Opcode : byte - { /// - /// Equivalent to numeric value 0. - /// Indicates a continuation frame. + /// Contains the values of the opcode that indicates the type of a WebSocket frame. /// - Cont = 0x0, - /// - /// Equivalent to numeric value 1. - /// Indicates a text frame. - /// - Text = 0x1, - /// - /// Equivalent to numeric value 2. - /// Indicates a binary frame. - /// - Binary = 0x2, - /// - /// Equivalent to numeric value 8. - /// Indicates a connection close frame. - /// - Close = 0x8, - /// - /// Equivalent to numeric value 9. - /// Indicates a ping frame. - /// - Ping = 0x9, - /// - /// Equivalent to numeric value 10. - /// Indicates a pong frame. - /// - Pong = 0xa - } + /// + /// The values of the opcode are defined in + /// Section 5.2 of RFC 6455. + /// + public enum Opcode : byte + { + /// + /// Equivalent to numeric value 0. + /// Indicates a continuation frame. + /// + Cont = 0x0, + /// + /// Equivalent to numeric value 1. + /// Indicates a text frame. + /// + Text = 0x1, + /// + /// Equivalent to numeric value 2. + /// Indicates a binary frame. + /// + Binary = 0x2, + /// + /// Equivalent to numeric value 8. + /// Indicates a connection close frame. + /// + Close = 0x8, + /// + /// Equivalent to numeric value 9. + /// Indicates a ping frame. + /// + Ping = 0x9, + /// + /// Equivalent to numeric value 10. + /// Indicates a pong frame. + /// + Pong = 0xa + } } diff --git a/SocketHttpListener/PayloadData.cs b/SocketHttpListener/PayloadData.cs index a6318da2b..829db6304 100644 --- a/SocketHttpListener/PayloadData.cs +++ b/SocketHttpListener/PayloadData.cs @@ -5,145 +5,155 @@ using System.Text; namespace SocketHttpListener { - internal class PayloadData : IEnumerable - { - #region Private Fields - - private byte [] _applicationData; - private byte [] _extensionData; - private bool _masked; - - #endregion - - #region Public Const Fields - - public const ulong MaxLength = long.MaxValue; - - #endregion - - #region Public Constructors - - public PayloadData () - : this (new byte [0], new byte [0], false) + internal class PayloadData : IEnumerable { - } + #region Private Fields + + private byte[] _applicationData; + private byte[] _extensionData; + private bool _masked; - public PayloadData (byte [] applicationData) - : this (new byte [0], applicationData, false) - { - } + #endregion + + #region Public Const Fields + + public const ulong MaxLength = long.MaxValue; + + #endregion + + #region Public Constructors + + public PayloadData() + : this(new byte[0], new byte[0], false) + { + } + + public PayloadData(byte[] applicationData) + : this(new byte[0], applicationData, false) + { + } - public PayloadData (string applicationData) - : this (new byte [0], Encoding.UTF8.GetBytes (applicationData), false) - { - } + public PayloadData(string applicationData) + : this(new byte[0], Encoding.UTF8.GetBytes(applicationData), false) + { + } + + public PayloadData(byte[] applicationData, bool masked) + : this(new byte[0], applicationData, masked) + { + } + + public PayloadData(byte[] extensionData, byte[] applicationData, bool masked) + { + _extensionData = extensionData; + _applicationData = applicationData; + _masked = masked; + } - public PayloadData (byte [] applicationData, bool masked) - : this (new byte [0], applicationData, masked) - { - } + #endregion + + #region Internal Properties - public PayloadData (byte [] extensionData, byte [] applicationData, bool masked) - { - _extensionData = extensionData; - _applicationData = applicationData; - _masked = masked; - } + internal bool ContainsReservedCloseStatusCode + { + get + { + return _applicationData.Length > 1 && + _applicationData.SubArray(0, 2).ToUInt16(ByteOrder.Big).IsReserved(); + } + } - #endregion + #endregion - #region Internal Properties + #region Public Properties - internal bool ContainsReservedCloseStatusCode { - get { - return _applicationData.Length > 1 && - _applicationData.SubArray (0, 2).ToUInt16 (ByteOrder.Big).IsReserved (); - } - } + public byte[] ApplicationData + { + get + { + return _applicationData; + } + } - #endregion + public byte[] ExtensionData + { + get + { + return _extensionData; + } + } - #region Public Properties + public bool IsMasked + { + get + { + return _masked; + } + } - public byte [] ApplicationData { - get { - return _applicationData; - } - } + public ulong Length + { + get + { + return (ulong)(_extensionData.Length + _applicationData.Length); + } + } - public byte [] ExtensionData { - get { - return _extensionData; - } - } + #endregion - public bool IsMasked { - get { - return _masked; - } - } + #region Private Methods - public ulong Length { - get { - return (ulong) (_extensionData.Length + _applicationData.Length); - } - } + private static void mask(byte[] src, byte[] key) + { + for (long i = 0; i < src.Length; i++) + src[i] = (byte)(src[i] ^ key[i % 4]); + } - #endregion + #endregion - #region Private Methods + #region Public Methods - private static void mask (byte [] src, byte [] key) - { - for (long i = 0; i < src.Length; i++) - src [i] = (byte) (src [i] ^ key [i % 4]); + public IEnumerator GetEnumerator() + { + foreach (byte b in _extensionData) + yield return b; + + foreach (byte b in _applicationData) + yield return b; + } + + public void Mask(byte[] maskingKey) + { + if (_extensionData.Length > 0) + mask(_extensionData, maskingKey); + + if (_applicationData.Length > 0) + mask(_applicationData, maskingKey); + + _masked = !_masked; + } + + public byte[] ToByteArray() + { + return _extensionData.Length > 0 + ? new List(this).ToArray() + : _applicationData; + } + + public override string ToString() + { + return BitConverter.ToString(ToByteArray()); + } + + #endregion + + #region Explicitly Implemented Interface Members + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion } - - #endregion - - #region Public Methods - - public IEnumerator GetEnumerator () - { - foreach (byte b in _extensionData) - yield return b; - - foreach (byte b in _applicationData) - yield return b; - } - - public void Mask (byte [] maskingKey) - { - if (_extensionData.Length > 0) - mask (_extensionData, maskingKey); - - if (_applicationData.Length > 0) - mask (_applicationData, maskingKey); - - _masked = !_masked; - } - - public byte [] ToByteArray () - { - return _extensionData.Length > 0 - ? new List (this).ToArray () - : _applicationData; - } - - public override string ToString () - { - return BitConverter.ToString (ToByteArray ()); - } - - #endregion - - #region Explicitly Implemented Interface Members - - IEnumerator IEnumerable.GetEnumerator () - { - return GetEnumerator (); - } - - #endregion - } } diff --git a/SocketHttpListener/Primitives/ITextEncoding.cs b/SocketHttpListener/Primitives/ITextEncoding.cs index a256a077d..f543cf4a5 100644 --- a/SocketHttpListener/Primitives/ITextEncoding.cs +++ b/SocketHttpListener/Primitives/ITextEncoding.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; +using System.Text; using MediaBrowser.Model.Text; namespace SocketHttpListener.Primitives diff --git a/SocketHttpListener/Rsv.cs b/SocketHttpListener/Rsv.cs index 668059b8a..87283791e 100644 --- a/SocketHttpListener/Rsv.cs +++ b/SocketHttpListener/Rsv.cs @@ -1,8 +1,8 @@ namespace SocketHttpListener { - internal enum Rsv : byte - { - Off = 0x0, - On = 0x1 - } + internal enum Rsv : byte + { + Off = 0x0, + On = 0x1 + } } diff --git a/SocketHttpListener/SocketStream.cs b/SocketHttpListener/SocketStream.cs index a4f31eab9..198fd36f2 100644 --- a/SocketHttpListener/SocketStream.cs +++ b/SocketHttpListener/SocketStream.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net.Sockets; -using System.Text; -using System.Threading.Tasks; namespace SocketHttpListener { diff --git a/SocketHttpListener/WebSocket.cs b/SocketHttpListener/WebSocket.cs index d926a58c9..98b9c776d 100644 --- a/SocketHttpListener/WebSocket.cs +++ b/SocketHttpListener/WebSocket.cs @@ -3,15 +3,12 @@ using System.Collections; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Sockets; using System.Text; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Cryptography; -using MediaBrowser.Model.IO; using SocketHttpListener.Net.WebSockets; -using SocketHttpListener.Primitives; using HttpStatusCode = SocketHttpListener.Net.HttpStatusCode; -using System.Net.Sockets; using WebSocketState = System.Net.WebSockets.WebSocketState; namespace SocketHttpListener diff --git a/SocketHttpListener/WebSocketException.cs b/SocketHttpListener/WebSocketException.cs index 260721317..e86c46d0f 100644 --- a/SocketHttpListener/WebSocketException.cs +++ b/SocketHttpListener/WebSocketException.cs @@ -2,59 +2,60 @@ using System; namespace SocketHttpListener { - /// - /// The exception that is thrown when a gets a fatal error. - /// - public class WebSocketException : Exception - { - #region Internal Constructors - - internal WebSocketException () - : this (CloseStatusCode.Abnormal, null, null) - { - } - - internal WebSocketException (string message) - : this (CloseStatusCode.Abnormal, message, null) - { - } - - internal WebSocketException (CloseStatusCode code) - : this (code, null, null) - { - } - - internal WebSocketException (string message, Exception innerException) - : this (CloseStatusCode.Abnormal, message, innerException) - { - } - - internal WebSocketException (CloseStatusCode code, string message) - : this (code, message, null) - { - } - - internal WebSocketException (CloseStatusCode code, string message, Exception innerException) - : base (message ?? code.GetMessage (), innerException) - { - Code = code; - } - - #endregion - - #region Public Properties - /// - /// Gets the status code indicating the cause for the exception. + /// The exception that is thrown when a gets a fatal error. /// - /// - /// One of the enum values, represents the status code indicating - /// the cause for the exception. - /// - public CloseStatusCode Code { - get; private set; + public class WebSocketException : Exception + { + #region Internal Constructors + + internal WebSocketException() + : this(CloseStatusCode.Abnormal, null, null) + { + } + + internal WebSocketException(string message) + : this(CloseStatusCode.Abnormal, message, null) + { + } + + internal WebSocketException(CloseStatusCode code) + : this(code, null, null) + { + } + + internal WebSocketException(string message, Exception innerException) + : this(CloseStatusCode.Abnormal, message, innerException) + { + } + + internal WebSocketException(CloseStatusCode code, string message) + : this(code, message, null) + { + } + + internal WebSocketException(CloseStatusCode code, string message, Exception innerException) + : base(message ?? code.GetMessage(), innerException) + { + Code = code; + } + + #endregion + + #region Public Properties + + /// + /// Gets the status code indicating the cause for the exception. + /// + /// + /// One of the enum values, represents the status code indicating + /// the cause for the exception. + /// + public CloseStatusCode Code + { + get; private set; + } + + #endregion } - - #endregion - } } diff --git a/SocketHttpListener/WebSocketFrame.cs b/SocketHttpListener/WebSocketFrame.cs index 44fa4a5dc..71543d36b 100644 --- a/SocketHttpListener/WebSocketFrame.cs +++ b/SocketHttpListener/WebSocketFrame.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; -using System.Text; namespace SocketHttpListener { -- cgit v1.2.3 From aacafee1de5003f0f9e7f01c5cc98fd111daafc5 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 13 Jan 2019 20:31:48 +0100 Subject: EditorConfig reformat: MediaBrowser.Providers, MediaBrowser.Tests, SocketHttpListener --- MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs | 2 +- MediaBrowser.Providers/Manager/SimplePriorityQueue.cs | 2 +- MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs | 2 +- MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs | 2 +- MediaBrowser.Tests/Properties/AssemblyInfo.cs | 2 +- SocketHttpListener/Ext.cs | 2 +- SocketHttpListener/HttpBase.cs | 2 +- SocketHttpListener/WebSocketFrame.cs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'SocketHttpListener/Ext.cs') diff --git a/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs b/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs index b9d8edd4d..801f422d6 100644 --- a/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs @@ -21,4 +21,4 @@ namespace Priority_Queue /// int MaxSize { get; } } -} \ No newline at end of file +} diff --git a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs index a2c5252ed..7f6194ea9 100644 --- a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs @@ -245,4 +245,4 @@ namespace Priority_Queue /// /// The type to enqueue public class SimplePriorityQueue : SimplePriorityQueue { } -} \ No newline at end of file +} diff --git a/MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs b/MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs index dde9f2fe2..adc24e095 100644 --- a/MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs +++ b/MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs @@ -83,4 +83,4 @@ namespace MediaBrowser.Tests.MediaEncoding.Subtitles { } } -} \ No newline at end of file +} diff --git a/MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs b/MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs index d9e48ac06..01ce78e4e 100644 --- a/MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs +++ b/MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs @@ -102,4 +102,4 @@ namespace MediaBrowser.Tests.MediaEncoding.Subtitles { Assert.AreEqual(expectedText, result); } } -} \ No newline at end of file +} diff --git a/MediaBrowser.Tests/Properties/AssemblyInfo.cs b/MediaBrowser.Tests/Properties/AssemblyInfo.cs index 700b2f508..ddbf746ef 100644 --- a/MediaBrowser.Tests/Properties/AssemblyInfo.cs +++ b/MediaBrowser.Tests/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MediaBrowser.Tests")] -[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyCopyright("Copyright � 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index 4a92f1c7d..6b7564828 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -958,4 +958,4 @@ namespace SocketHttpListener #endregion } -} \ No newline at end of file +} diff --git a/SocketHttpListener/HttpBase.cs b/SocketHttpListener/HttpBase.cs index 4dffe3223..8504b47d7 100644 --- a/SocketHttpListener/HttpBase.cs +++ b/SocketHttpListener/HttpBase.cs @@ -97,4 +97,4 @@ namespace SocketHttpListener #endregion } -} \ No newline at end of file +} diff --git a/SocketHttpListener/WebSocketFrame.cs b/SocketHttpListener/WebSocketFrame.cs index 71543d36b..c695c605c 100644 --- a/SocketHttpListener/WebSocketFrame.cs +++ b/SocketHttpListener/WebSocketFrame.cs @@ -574,4 +574,4 @@ namespace SocketHttpListener #endregion } -} \ No newline at end of file +} -- cgit v1.2.3 From 65bd052f3e8682d177520af57db1c8ef5cb33262 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 13 Jan 2019 21:37:13 +0100 Subject: ReSharper conform to 'var' settings --- BDInfo/BDROM.cs | 42 +- BDInfo/TSCodecDTSHD.cs | 2 +- BDInfo/TSPlaylistFile.cs | 76 +-- BDInfo/TSStream.cs | 12 +- BDInfo/TSStreamBuffer.cs | 2 +- BDInfo/TSStreamClip.cs | 4 +- BDInfo/TSStreamClipFile.cs | 12 +- BDInfo/TSStreamFile.cs | 34 +- DvdLib/Ifo/Dvd.cs | 10 +- DvdLib/Ifo/ProgramChain.cs | 4 +- DvdLib/Ifo/Title.cs | 2 +- Emby.Dlna/Api/DlnaServerService.cs | 2 +- Emby.Dlna/ContentDirectory/ControlHandler.cs | 4 +- Emby.Dlna/Didl/DidlBuilder.cs | 2 +- Emby.Dlna/PlayTo/PlayToController.cs | 2 +- Emby.Dlna/Service/BaseControlHandler.cs | 2 +- Emby.Dlna/Service/ControlErrorHandler.cs | 2 +- Emby.Drawing.Skia/StripCollageBuilder.cs | 4 +- Emby.Drawing/Common/ImageHeader.cs | 4 +- Emby.Drawing/ImageProcessor.cs | 8 +- Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs | 2 +- Emby.Naming/AudioBook/AudioBookFilePathParser.cs | 2 +- Emby.Naming/TV/EpisodePathParser.cs | 2 +- Emby.Naming/Video/VideoResolver.cs | 2 +- .../Activity/ActivityLogEntryPoint.cs | 4 +- .../AppBase/BaseConfigurationManager.cs | 4 +- Emby.Server.Implementations/ApplicationHost.cs | 12 +- .../Configuration/ServerConfigurationManager.cs | 6 +- .../Data/ManagedConnection.cs | 2 +- .../Data/SqliteDisplayPreferencesRepository.cs | 8 +- .../Data/SqliteExtensions.cs | 2 +- .../Data/SqliteItemRepository.cs | 12 +- .../Data/SqliteUserDataRepository.cs | 4 +- .../Data/SqliteUserRepository.cs | 2 +- Emby.Server.Implementations/Data/TypeMapper.cs | 2 +- Emby.Server.Implementations/Dto/DtoService.cs | 4 +- .../EntryPoints/RecordingNotifier.cs | 2 +- .../HttpClientManager/HttpClientManager.cs | 12 +- .../HttpServer/WebSocketConnection.cs | 4 +- Emby.Server.Implementations/IO/IsoManager.cs | 4 +- Emby.Server.Implementations/IO/LibraryMonitor.cs | 2 +- .../IO/ManagedFileSystem.cs | 12 +- .../Library/LibraryManager.cs | 12 +- .../Library/MediaSourceManager.cs | 2 +- .../Library/PathExtensions.cs | 2 +- .../Library/ResolverHelper.cs | 2 +- .../Library/Resolvers/BaseVideoResolver.cs | 2 +- .../Library/Resolvers/TV/SeasonResolver.cs | 2 +- .../Library/Resolvers/TV/SeriesResolver.cs | 4 +- .../Library/SearchEngine.cs | 2 +- .../Library/UserDataManager.cs | 2 +- Emby.Server.Implementations/Library/UserManager.cs | 18 +- .../LiveTv/EmbyTV/EmbyTV.cs | 6 +- .../LiveTv/Listings/SchedulesDirect.cs | 24 +- .../LiveTv/Listings/XmlTvListingsProvider.cs | 4 +- .../LiveTv/LiveTvManager.cs | 10 +- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 2 +- .../TunerHosts/HdHomerun/HdHomerunManager.cs | 4 +- .../Net/DisposableManagedObjectBase.cs | 4 +- Emby.Server.Implementations/Net/UdpSocket.cs | 4 +- .../Networking/IPNetwork/BigIntegerExt.cs | 8 +- .../Networking/IPNetwork/IPAddressCollection.cs | 2 +- .../Networking/IPNetwork/IPNetwork.cs | 108 ++--- .../Networking/IPNetwork/IPNetworkCollection.cs | 10 +- .../Networking/NetworkManager.cs | 14 +- .../Playlists/PlaylistManager.cs | 6 +- .../ScheduledTasks/ScheduledTaskWorker.cs | 12 +- .../ScheduledTasks/TaskManager.cs | 2 +- .../Security/EncryptionManager.cs | 4 +- .../Serialization/JsonSerializer.cs | 24 +- .../Services/ServiceController.cs | 2 +- .../Session/SessionManager.cs | 22 +- .../Sorting/AlphanumComparator.cs | 4 +- Emby.Server.Implementations/TV/TVSeriesManager.cs | 4 +- .../TextEncoding/NLangDetect/Detector.cs | 12 +- .../TextEncoding/NLangDetect/DetectorFactory.cs | 2 +- .../TextEncoding/NLangDetect/GenProfile.cs | 6 +- .../TextEncoding/NLangDetect/LanguageDetector.cs | 2 +- .../TextEncoding/NLangDetect/Utils/LangProfile.cs | 6 +- .../TextEncoding/NLangDetect/Utils/Messages.cs | 2 +- .../TextEncoding/TextEncodingDetect.cs | 2 +- .../Core/CharDistributionAnalyser.cs | 4 +- .../UniversalDetector/Core/CharsetProber.cs | 4 +- .../UniversalDetector/Core/EscCharsetProber.cs | 2 +- .../UniversalDetector/Core/MBCSGroupProber.cs | 2 +- .../UniversalDetector/Core/SBCSGroupProber.cs | 4 +- .../UniversalDetector/Core/UniversalDetector.cs | 2 +- .../Updates/InstallationManager.cs | 4 +- Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs | 2 +- Jellyfin.Server/Program.cs | 10 +- Jellyfin.Server/SocketSharp/RequestMono.cs | 14 +- MediaBrowser.Api/Library/LibraryService.cs | 2 +- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- .../ScheduledTasks/ScheduledTaskService.cs | 8 +- MediaBrowser.Api/SimilarItemsHelper.cs | 2 +- MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 6 +- MediaBrowser.Common/Net/IHttpClient.cs | 2 +- MediaBrowser.Common/Plugins/BasePlugin.cs | 2 +- MediaBrowser.Common/Plugins/IPlugin.cs | 2 +- .../Updates/IInstallationManager.cs | 4 +- .../Entities/AggregateFolder.cs | 4 +- MediaBrowser.Controller/Entities/BaseItem.cs | 26 +- MediaBrowser.Controller/Entities/Folder.cs | 4 +- MediaBrowser.Controller/Entities/Person.cs | 4 +- MediaBrowser.Controller/Entities/TV/Series.cs | 4 +- MediaBrowser.Controller/Entities/User.cs | 2 +- MediaBrowser.Controller/Entities/UserItemData.cs | 2 +- MediaBrowser.Controller/IO/FileData.cs | 2 +- MediaBrowser.Controller/Library/ILibraryManager.cs | 2 +- MediaBrowser.Controller/Library/IUserManager.cs | 18 +- MediaBrowser.Controller/Library/ItemResolveArgs.cs | 10 +- .../Net/IWebSocketConnection.cs | 4 +- MediaBrowser.Controller/Session/ISessionManager.cs | 4 +- MediaBrowser.Controller/Sorting/SortExtensions.cs | 4 +- .../Images/LocalImageProvider.cs | 2 +- .../Parsers/BaseItemXmlParser.cs | 14 +- MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs | 2 +- .../Encoder/EncoderValidator.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 2 +- .../Probing/ProbeResultNormalizer.cs | 14 +- MediaBrowser.MediaEncoding/Subtitles/AssParser.cs | 2 +- MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs | 2 +- MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs | 2 +- .../Subtitles/SubtitleEncoder.cs | 6 +- MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs | 4 +- MediaBrowser.Model/Configuration/LibraryOptions.cs | 4 +- MediaBrowser.Model/Dlna/ConditionProcessor.cs | 2 +- MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs | 16 +- MediaBrowser.Model/Dlna/DeviceProfile.cs | 8 +- .../Dlna/MediaFormatProfileResolver.cs | 2 +- MediaBrowser.Model/Dlna/StreamBuilder.cs | 114 ++--- MediaBrowser.Model/Dlna/StreamInfo.cs | 62 +-- MediaBrowser.Model/Dto/MediaSourceInfo.cs | 16 +- MediaBrowser.Model/Entities/MediaStream.cs | 6 +- MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs | 2 +- MediaBrowser.Model/Net/MimeTypes.cs | 4 +- .../Notifications/NotificationOptions.cs | 10 +- MediaBrowser.Model/Services/HttpUtility.cs | 6 +- MediaBrowser.Model/System/IEnvironmentInfo.cs | 2 +- .../Manager/GenericPriorityQueue.cs | 12 +- MediaBrowser.Providers/Manager/ImageSaver.cs | 10 +- MediaBrowser.Providers/Manager/MetadataService.cs | 2 +- .../Manager/SimplePriorityQueue.cs | 8 +- MediaBrowser.Providers/Movies/MovieDbProvider.cs | 4 +- .../Music/ArtistMetadataService.cs | 2 +- MediaBrowser.Providers/Omdb/OmdbImageProvider.cs | 2 +- MediaBrowser.Providers/Omdb/OmdbProvider.cs | 10 +- .../People/MovieDbPersonProvider.cs | 4 +- .../Playlists/PlaylistItemsProvider.cs | 2 +- .../Subtitles/SubtitleManager.cs | 4 +- .../TV/TheTVDB/TvdbSeriesProvider.cs | 2 +- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 6 +- MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs | 2 +- Mono.Nat/Mapping.cs | 2 +- Mono.Nat/Pmp/PmpNatDevice.cs | 2 +- Mono.Nat/Pmp/PmpSearcher.cs | 20 +- .../Messages/Requests/CreatePortMappingMessage.cs | 6 +- Mono.Nat/Upnp/Messages/UpnpMessage.cs | 2 +- Mono.Nat/Upnp/Searchers/UpnpSearcher.cs | 2 +- Mono.Nat/Upnp/UpnpNatDevice.cs | 14 +- OpenSubtitlesHandler/Console/OSHConsole.cs | 2 +- OpenSubtitlesHandler/MovieHasher.cs | 2 +- OpenSubtitlesHandler/OpenSubtitles.cs | 526 ++++++++++----------- OpenSubtitlesHandler/Utilities.cs | 6 +- .../XML-RPC/Values/XmlRpcValueArray.cs | 8 +- OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs | 36 +- RSSDP/DeviceAvailableEventArgs.cs | 28 +- RSSDP/DeviceEventArgs.cs | 2 +- RSSDP/DeviceUnavailableEventArgs.cs | 6 +- RSSDP/DiscoveredSsdpDevice.cs | 2 +- RSSDP/DisposableManagedObjectBase.cs | 4 +- RSSDP/HttpParserBase.cs | 12 +- RSSDP/HttpRequestParser.cs | 14 +- RSSDP/HttpResponseParser.cs | 14 +- RSSDP/ISsdpDeviceLocator.cs | 2 +- RSSDP/ISsdpDevicePublisher.cs | 4 +- RSSDP/SsdpCommunicationsServer.cs | 12 +- RSSDP/SsdpDevice.cs | 6 +- RSSDP/SsdpDeviceLocator.cs | 4 +- RSSDP/SsdpDevicePublisher.cs | 10 +- SocketHttpListener/Ext.cs | 2 +- SocketHttpListener/MessageEventArgs.cs | 4 +- SocketHttpListener/Net/ChunkStream.cs | 8 +- SocketHttpListener/Net/ChunkedInputStream.cs | 14 +- SocketHttpListener/Net/HttpConnection.cs | 8 +- SocketHttpListener/Net/HttpEndPointListener.cs | 26 +- SocketHttpListener/Net/HttpEndPointManager.cs | 10 +- .../Net/HttpListenerContext.Managed.cs | 2 +- .../Net/HttpListenerRequest.Managed.cs | 4 +- SocketHttpListener/Net/HttpListenerRequest.cs | 10 +- .../Net/HttpListenerRequestUriBuilder.cs | 10 +- .../Net/HttpListenerResponse.Managed.cs | 4 +- .../Net/HttpRequestStream.Managed.cs | 4 +- .../Net/HttpResponseStream.Managed.cs | 12 +- SocketHttpListener/Net/ListenerPrefix.cs | 2 +- SocketHttpListener/Net/WebHeaderCollection.cs | 4 +- .../Net/WebSockets/HttpWebSocket.Managed.cs | 10 +- SocketHttpListener/Net/WebSockets/HttpWebSocket.cs | 2 +- .../Net/WebSockets/WebSocketValidate.cs | 2 +- 199 files changed, 1063 insertions(+), 1063 deletions(-) (limited to 'SocketHttpListener/Ext.cs') diff --git a/BDInfo/BDROM.cs b/BDInfo/BDROM.cs index 0b2eefcc0..2fadf3b77 100644 --- a/BDInfo/BDROM.cs +++ b/BDInfo/BDROM.cs @@ -164,7 +164,7 @@ namespace BDInfo if (DirectoryPLAYLIST != null) { FileSystemMetadata[] files = GetFiles(DirectoryPLAYLIST.FullName, ".mpls").ToArray(); - foreach (FileSystemMetadata file in files) + foreach (var file in files) { PlaylistFiles.Add( file.Name.ToUpper(), new TSPlaylistFile(this, file, _fileSystem, textEncoding)); @@ -174,7 +174,7 @@ namespace BDInfo if (DirectorySTREAM != null) { FileSystemMetadata[] files = GetFiles(DirectorySTREAM.FullName, ".m2ts").ToArray(); - foreach (FileSystemMetadata file in files) + foreach (var file in files) { StreamFiles.Add( file.Name.ToUpper(), new TSStreamFile(file, _fileSystem)); @@ -184,7 +184,7 @@ namespace BDInfo if (DirectoryCLIPINF != null) { FileSystemMetadata[] files = GetFiles(DirectoryCLIPINF.FullName, ".clpi").ToArray(); - foreach (FileSystemMetadata file in files) + foreach (var file in files) { StreamClipFiles.Add( file.Name.ToUpper(), new TSStreamClipFile(file, _fileSystem, textEncoding)); @@ -194,7 +194,7 @@ namespace BDInfo if (DirectorySSIF != null) { FileSystemMetadata[] files = GetFiles(DirectorySSIF.FullName, ".ssif").ToArray(); - foreach (FileSystemMetadata file in files) + foreach (var file in files) { InterleavedFiles.Add( file.Name.ToUpper(), new TSInterleavedFile(file)); @@ -214,8 +214,8 @@ namespace BDInfo public void Scan() { - List errorStreamClipFiles = new List(); - foreach (TSStreamClipFile streamClipFile in StreamClipFiles.Values) + var errorStreamClipFiles = new List(); + foreach (var streamClipFile in StreamClipFiles.Values) { try { @@ -239,7 +239,7 @@ namespace BDInfo } } - foreach (TSStreamFile streamFile in StreamFiles.Values) + foreach (var streamFile in StreamFiles.Values) { string ssifName = Path.GetFileNameWithoutExtension(streamFile.Name) + ".SSIF"; if (InterleavedFiles.ContainsKey(ssifName)) @@ -252,8 +252,8 @@ namespace BDInfo StreamFiles.Values.CopyTo(streamFiles, 0); Array.Sort(streamFiles, CompareStreamFiles); - List errorPlaylistFiles = new List(); - foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values) + var errorPlaylistFiles = new List(); + foreach (var playlistFile in PlaylistFiles.Values) { try { @@ -277,15 +277,15 @@ namespace BDInfo } } - List errorStreamFiles = new List(); - foreach (TSStreamFile streamFile in streamFiles) + var errorStreamFiles = new List(); + foreach (var streamFile in streamFiles) { try { - List playlists = new List(); - foreach (TSPlaylistFile playlist in PlaylistFiles.Values) + var playlists = new List(); + foreach (var playlist in PlaylistFiles.Values) { - foreach (TSStreamClip streamClip in playlist.StreamClips) + foreach (var streamClip in playlist.StreamClips) { if (streamClip.Name == streamFile.Name) { @@ -314,12 +314,12 @@ namespace BDInfo } } - foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values) + foreach (var playlistFile in PlaylistFiles.Values) { playlistFile.Initialize(); if (!Is50Hz) { - foreach (TSVideoStream videoStream in playlistFile.VideoStreams) + foreach (var videoStream in playlistFile.VideoStreams) { if (videoStream.FrameRate == TSFrameRate.FRAMERATE_25 || videoStream.FrameRate == TSFrameRate.FRAMERATE_50) @@ -339,7 +339,7 @@ namespace BDInfo throw new ArgumentNullException(nameof(path)); } - FileSystemMetadata dir = _fileSystem.GetDirectoryInfo(path); + var dir = _fileSystem.GetDirectoryInfo(path); while (dir != null) { @@ -369,7 +369,7 @@ namespace BDInfo if (dir != null) { FileSystemMetadata[] children = _fileSystem.GetDirectories(dir.FullName).ToArray(); - foreach (FileSystemMetadata child in children) + foreach (var child in children) { if (string.Equals(child.Name, name, StringComparison.OrdinalIgnoreCase)) { @@ -378,7 +378,7 @@ namespace BDInfo } if (searchDepth > 0) { - foreach (FileSystemMetadata child in children) + foreach (var child in children) { GetDirectory( name, child, searchDepth - 1); @@ -395,7 +395,7 @@ namespace BDInfo //if (!ExcludeDirs.Contains(directoryInfo.Name.ToUpper())) // TODO: Keep? { FileSystemMetadata[] pathFiles = _fileSystem.GetFiles(directoryInfo.FullName).ToArray(); - foreach (FileSystemMetadata pathFile in pathFiles) + foreach (var pathFile in pathFiles) { if (pathFile.Extension.ToUpper() == ".SSIF") { @@ -405,7 +405,7 @@ namespace BDInfo } FileSystemMetadata[] pathChildren = _fileSystem.GetDirectories(directoryInfo.FullName).ToArray(); - foreach (FileSystemMetadata pathChild in pathChildren) + foreach (var pathChild in pathChildren) { size += GetDirectorySize(pathChild); } diff --git a/BDInfo/TSCodecDTSHD.cs b/BDInfo/TSCodecDTSHD.cs index f2315d4c5..57a136d2d 100644 --- a/BDInfo/TSCodecDTSHD.cs +++ b/BDInfo/TSCodecDTSHD.cs @@ -211,7 +211,7 @@ namespace BDInfo // TODO if (stream.CoreStream != null) { - TSAudioStream coreStream = (TSAudioStream)stream.CoreStream; + var coreStream = (TSAudioStream)stream.CoreStream; if (coreStream.AudioMode == TSAudioMode.Extended && stream.ChannelCount == 5) { diff --git a/BDInfo/TSPlaylistFile.cs b/BDInfo/TSPlaylistFile.cs index aa1f175d3..ba0b37f00 100644 --- a/BDInfo/TSPlaylistFile.cs +++ b/BDInfo/TSPlaylistFile.cs @@ -85,9 +85,9 @@ namespace BDInfo _fileSystem = fileSystem; _textEncoding = textEncoding; IsCustom = true; - foreach (TSStreamClip clip in clips) + foreach (var clip in clips) { - TSStreamClip newClip = new TSStreamClip( + var newClip = new TSStreamClip( clip.StreamFile, clip.StreamClipFile); newClip.Name = clip.Name; @@ -123,7 +123,7 @@ namespace BDInfo get { ulong size = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { size += clip.InterleavedFileSize; } @@ -135,7 +135,7 @@ namespace BDInfo get { ulong size = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { size += clip.FileSize; } @@ -147,7 +147,7 @@ namespace BDInfo get { double length = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { if (clip.AngleIndex == 0) { @@ -163,7 +163,7 @@ namespace BDInfo get { double length = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { length += clip.Length; } @@ -176,7 +176,7 @@ namespace BDInfo get { ulong size = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { if (clip.AngleIndex == 0) { @@ -192,7 +192,7 @@ namespace BDInfo get { ulong size = 0; - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { size += clip.PacketSize; } @@ -263,7 +263,7 @@ namespace BDInfo int itemCount = ReadInt16(data, ref pos); int subitemCount = ReadInt16(data, ref pos); - List chapterClips = new List(); + var chapterClips = new List(); for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) { int itemStart = pos; @@ -310,7 +310,7 @@ namespace BDInfo if (outTime < 0) outTime &= 0x7FFFFFFF; double timeOut = (double)outTime / 45000; - TSStreamClip streamClip = new TSStreamClip( + var streamClip = new TSStreamClip( streamFile, streamClipFile); streamClip.Name = streamFileName; //TODO @@ -361,7 +361,7 @@ namespace BDInfo FileInfo.Name, angleClipFileName)); } - TSStreamClip angleClip = + var angleClip = new TSStreamClip(angleFile, angleClipFile); angleClip.AngleIndex = angle + 1; angleClip.TimeIn = streamClip.TimeIn; @@ -394,33 +394,33 @@ namespace BDInfo for (int i = 0; i < streamCountVideo; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; } for (int i = 0; i < streamCountAudio; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; } for (int i = 0; i < streamCountPG; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; } for (int i = 0; i < streamCountIG; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; } for (int i = 0; i < streamCountSecondaryAudio; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; pos += 2; } for (int i = 0; i < streamCountSecondaryVideo; i++) { - TSStream stream = CreatePlaylistStream(data, ref pos); + var stream = CreatePlaylistStream(data, ref pos); if (stream != null) PlaylistStreams[stream.PID] = stream; pos += 6; } @@ -458,7 +458,7 @@ namespace BDInfo ((long)data[pos + 6] << 8) + ((long)data[pos + 7]); - TSStreamClip streamClip = chapterClips[streamFileIndex]; + var streamClip = chapterClips[streamFileIndex]; double chapterSeconds = (double)chapterTime / 45000; @@ -498,8 +498,8 @@ namespace BDInfo { LoadStreamClips(); - Dictionary> clipTimes = new Dictionary>(); - foreach (TSStreamClip clip in StreamClips) + var clipTimes = new Dictionary>(); + foreach (var clip in StreamClips) { if (clip.AngleIndex == 0) { @@ -567,7 +567,7 @@ namespace BDInfo int streamLength = data[pos++]; int streamPos = pos; - TSStreamType streamType = (TSStreamType)data[pos++]; + var streamType = (TSStreamType)data[pos++]; switch (streamType) { case TSStreamType.MVC_VIDEO: @@ -579,11 +579,11 @@ namespace BDInfo case TSStreamType.MPEG2_VIDEO: case TSStreamType.VC1_VIDEO: - TSVideoFormat videoFormat = (TSVideoFormat) + var videoFormat = (TSVideoFormat) (data[pos] >> 4); - TSFrameRate frameRate = (TSFrameRate) + var frameRate = (TSFrameRate) (data[pos] & 0xF); - TSAspectRatio aspectRatio = (TSAspectRatio) + var aspectRatio = (TSAspectRatio) (data[pos + 1] >> 4); stream = new TSVideoStream(); @@ -617,9 +617,9 @@ namespace BDInfo int audioFormat = ReadByte(data, ref pos); - TSChannelLayout channelLayout = (TSChannelLayout) + var channelLayout = (TSChannelLayout) (audioFormat >> 4); - TSSampleRate sampleRate = (TSSampleRate) + var sampleRate = (TSSampleRate) (audioFormat & 0xF); string audioLanguage = ReadString(data, 3, ref pos); @@ -712,7 +712,7 @@ namespace BDInfo { referenceClip = StreamClips[0]; } - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { if (clip.StreamClipFile.Streams.Count > referenceClip.StreamClipFile.Streams.Count) { @@ -738,12 +738,12 @@ namespace BDInfo } } - foreach (TSStream clipStream + foreach (var clipStream in referenceClip.StreamClipFile.Streams.Values) { if (!Streams.ContainsKey(clipStream.PID)) { - TSStream stream = clipStream.Clone(); + var stream = clipStream.Clone(); Streams[clipStream.PID] = stream; if (!IsCustom && !PlaylistStreams.ContainsKey(stream.PID)) @@ -779,7 +779,7 @@ namespace BDInfo referenceClip.StreamFile.Streams.ContainsKey(4114) && !Streams.ContainsKey(4114)) { - TSStream stream = referenceClip.StreamFile.Streams[4114].Clone(); + var stream = referenceClip.StreamFile.Streams[4114].Clone(); Streams[4114] = stream; if (stream.IsVideoStream) { @@ -787,12 +787,12 @@ namespace BDInfo } } - foreach (TSStream clipStream + foreach (var clipStream in referenceClip.StreamFile.Streams.Values) { if (Streams.ContainsKey(clipStream.PID)) { - TSStream stream = Streams[clipStream.PID]; + var stream = Streams[clipStream.PID]; if (stream.StreamType != clipStream.StreamType) continue; @@ -811,8 +811,8 @@ namespace BDInfo else if (stream.IsAudioStream && clipStream.IsAudioStream) { - TSAudioStream audioStream = (TSAudioStream)stream; - TSAudioStream clipAudioStream = (TSAudioStream)clipStream; + var audioStream = (TSAudioStream)stream; + var clipAudioStream = (TSAudioStream)clipStream; if (clipAudioStream.ChannelCount > audioStream.ChannelCount) { @@ -863,7 +863,7 @@ namespace BDInfo SortedStreams.Add(stream); for (int i = 0; i < AngleCount; i++) { - TSStream angleStream = stream.Clone(); + var angleStream = stream.Clone(); angleStream.AngleIndex = i + 1; AngleStreams[i][angleStream.PID] = angleStream; SortedStreams.Add(angleStream); @@ -900,7 +900,7 @@ namespace BDInfo public void ClearBitrates() { - foreach (TSStreamClip clip in StreamClips) + foreach (var clip in StreamClips) { clip.PayloadBytes = 0; clip.PacketCount = 0; @@ -908,7 +908,7 @@ namespace BDInfo if (clip.StreamFile != null) { - foreach (TSStream stream in clip.StreamFile.Streams.Values) + foreach (var stream in clip.StreamFile.Streams.Values) { stream.PayloadBytes = 0; stream.PacketCount = 0; @@ -923,7 +923,7 @@ namespace BDInfo } } - foreach (TSStream stream in SortedStreams) + foreach (var stream in SortedStreams) { stream.PayloadBytes = 0; stream.PacketCount = 0; diff --git a/BDInfo/TSStream.cs b/BDInfo/TSStream.cs index fad3f1acb..3c30a8597 100644 --- a/BDInfo/TSStream.cs +++ b/BDInfo/TSStream.cs @@ -109,7 +109,7 @@ namespace BDInfo public TSDescriptor Clone() { - TSDescriptor descriptor = + var descriptor = new TSDescriptor(Name, (byte)Value.Length); Value.CopyTo(descriptor.Value, 0); return descriptor; @@ -404,7 +404,7 @@ namespace BDInfo if (Descriptors != null) { stream.Descriptors = new List(); - foreach (TSDescriptor descriptor in Descriptors) + foreach (var descriptor in Descriptors) { stream.Descriptors.Add(descriptor.Clone()); } @@ -553,7 +553,7 @@ namespace BDInfo public override TSStream Clone() { - TSVideoStream stream = new TSVideoStream(); + var stream = new TSVideoStream(); CopyTo(stream); stream.VideoFormat = _VideoFormat; @@ -727,7 +727,7 @@ namespace BDInfo public override TSStream Clone() { - TSAudioStream stream = new TSAudioStream(); + var stream = new TSAudioStream(); CopyTo(stream); stream.SampleRate = SampleRate; @@ -756,7 +756,7 @@ namespace BDInfo public override TSStream Clone() { - TSGraphicsStream stream = new TSGraphicsStream(); + var stream = new TSGraphicsStream(); CopyTo(stream); return stream; } @@ -772,7 +772,7 @@ namespace BDInfo public override TSStream Clone() { - TSTextStream stream = new TSTextStream(); + var stream = new TSTextStream(); CopyTo(stream); return stream; } diff --git a/BDInfo/TSStreamBuffer.cs b/BDInfo/TSStreamBuffer.cs index 17025c2e3..30bd1a3f4 100644 --- a/BDInfo/TSStreamBuffer.cs +++ b/BDInfo/TSStreamBuffer.cs @@ -111,7 +111,7 @@ namespace BDInfo data += (Stream.ReadByte() << shift); shift -= 8; } - BitVector32 vector = new BitVector32(data); + var vector = new BitVector32(data); int value = 0; for (int i = SkipBits; i < SkipBits + bits; i++) diff --git a/BDInfo/TSStreamClip.cs b/BDInfo/TSStreamClip.cs index 20f795e53..295eeb6b1 100644 --- a/BDInfo/TSStreamClip.cs +++ b/BDInfo/TSStreamClip.cs @@ -90,11 +90,11 @@ namespace BDInfo public bool IsCompatible(TSStreamClip clip) { - foreach (TSStream stream1 in StreamFile.Streams.Values) + foreach (var stream1 in StreamFile.Streams.Values) { if (clip.StreamFile.Streams.ContainsKey(stream1.PID)) { - TSStream stream2 = clip.StreamFile.Streams[stream1.PID]; + var stream2 = clip.StreamFile.Streams[stream1.PID]; if (stream1.StreamType != stream2.StreamType) { return false; diff --git a/BDInfo/TSStreamClipFile.cs b/BDInfo/TSStreamClipFile.cs index 6aed7e4d4..be6299e1a 100644 --- a/BDInfo/TSStreamClipFile.cs +++ b/BDInfo/TSStreamClipFile.cs @@ -114,7 +114,7 @@ namespace BDInfo streamOffset += 2; - TSStreamType streamType = (TSStreamType) + var streamType = (TSStreamType) clipData[streamOffset + 1]; switch (streamType) { @@ -127,11 +127,11 @@ namespace BDInfo case TSStreamType.MPEG2_VIDEO: case TSStreamType.VC1_VIDEO: { - TSVideoFormat videoFormat = (TSVideoFormat) + var videoFormat = (TSVideoFormat) (clipData[streamOffset + 2] >> 4); - TSFrameRate frameRate = (TSFrameRate) + var frameRate = (TSFrameRate) (clipData[streamOffset + 2] & 0xF); - TSAspectRatio aspectRatio = (TSAspectRatio) + var aspectRatio = (TSAspectRatio) (clipData[streamOffset + 3] >> 4); stream = new TSVideoStream(); @@ -168,9 +168,9 @@ namespace BDInfo string languageCode = _textEncoding.GetASCIIEncoding().GetString(languageBytes, 0, languageBytes.Length); - TSChannelLayout channelLayout = (TSChannelLayout) + var channelLayout = (TSChannelLayout) (clipData[streamOffset + 2] >> 4); - TSSampleRate sampleRate = (TSSampleRate) + var sampleRate = (TSSampleRate) (clipData[streamOffset + 2] & 0xF); stream = new TSAudioStream(); diff --git a/BDInfo/TSStreamFile.cs b/BDInfo/TSStreamFile.cs index 29d105da0..ecf6609e2 100644 --- a/BDInfo/TSStreamFile.cs +++ b/BDInfo/TSStreamFile.cs @@ -283,7 +283,7 @@ namespace BDInfo bool isAVC = false; bool isMVC = false; - foreach (TSStream finishedStream in Streams.Values) + foreach (var finishedStream in Streams.Values) { if (!finishedStream.IsInitialized) { @@ -327,10 +327,10 @@ namespace BDInfo UpdateStreamBitrate(PID, PTSPID, PTS, PTSDiff); } - foreach (TSPlaylistFile playlist in Playlists) + foreach (var playlist in Playlists) { double packetSeconds = 0; - foreach (TSStreamClip clip in playlist.StreamClips) + foreach (var clip in playlist.StreamClips) { if (clip.AngleIndex == 0) { @@ -339,7 +339,7 @@ namespace BDInfo } if (packetSeconds > 0) { - foreach (TSStream playlistStream in playlist.SortedStreams) + foreach (var playlistStream in playlist.SortedStreams) { if (playlistStream.IsVBR) { @@ -366,14 +366,14 @@ namespace BDInfo { if (Playlists == null) return; - TSStreamState streamState = StreamStates[PID]; + var streamState = StreamStates[PID]; double streamTime = (double)PTS / 90000; double streamInterval = (double)PTSDiff / 90000; double streamOffset = streamTime + streamInterval; - foreach (TSPlaylistFile playlist in Playlists) + foreach (var playlist in Playlists) { - foreach (TSStreamClip clip in playlist.StreamClips) + foreach (var clip in playlist.StreamClips) { if (clip.Name != this.Name) continue; @@ -390,7 +390,7 @@ namespace BDInfo clip.PacketSeconds = streamOffset - clip.TimeIn; } - Dictionary playlistStreams = playlist.Streams; + var playlistStreams = playlist.Streams; if (clip.AngleIndex > 0 && clip.AngleIndex < playlist.AngleStreams.Count + 1) { @@ -398,7 +398,7 @@ namespace BDInfo } if (playlistStreams.ContainsKey(PID)) { - TSStream stream = playlistStreams[PID]; + var stream = playlistStreams[PID]; stream.PayloadBytes += streamState.WindowBytes; stream.PacketCount += streamState.WindowPackets; @@ -425,13 +425,13 @@ namespace BDInfo if (Streams.ContainsKey(PID)) { - TSStream stream = Streams[PID]; + var stream = Streams[PID]; stream.PayloadBytes += streamState.WindowBytes; stream.PacketCount += streamState.WindowPackets; if (stream.IsVideoStream) { - TSStreamDiagnostics diag = new TSStreamDiagnostics(); + var diag = new TSStreamDiagnostics(); diag.Marker = (double)PTS / 90000; diag.Interval = (double)PTSDiff / 90000; diag.Bytes = streamState.WindowBytes; @@ -482,7 +482,7 @@ namespace BDInfo StreamStates.Clear(); StreamDiagnostics.Clear(); - TSPacketParser parser = + var parser = new TSPacketParser(); long fileLength = (uint)fileStream.Length; @@ -839,7 +839,7 @@ namespace BDInfo if (!Streams.ContainsKey(streamPID)) { - List streamDescriptors = + var streamDescriptors = new List(); /* @@ -996,7 +996,7 @@ namespace BDInfo { --parser.PMTProgramDescriptorLength; - TSDescriptor descriptor = parser.PMTProgramDescriptors[ + var descriptor = parser.PMTProgramDescriptors[ parser.PMTProgramDescriptors.Count - 1]; int valueIndex = @@ -1026,8 +1026,8 @@ namespace BDInfo parser.StreamState != null && parser.TransportScramblingControl == 0) { - TSStream stream = parser.Stream; - TSStreamState streamState = parser.StreamState; + var stream = parser.Stream; + var streamState = parser.StreamState; streamState.Parse = (streamState.Parse << 8) + buffer[i]; @@ -1461,7 +1461,7 @@ namespace BDInfo ulong PTSLast = 0; ulong PTSDiff = 0; - foreach (TSStream stream in Streams.Values) + foreach (var stream in Streams.Values) { if (!stream.IsVideoStream) continue; diff --git a/DvdLib/Ifo/Dvd.cs b/DvdLib/Ifo/Dvd.cs index a8f2ab970..71ba2d5e4 100644 --- a/DvdLib/Ifo/Dvd.cs +++ b/DvdLib/Ifo/Dvd.cs @@ -45,7 +45,7 @@ namespace DvdLib.Ifo { using (var vmgFs = _fileSystem.GetFileStream(vmgPath.FullName, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read)) { - using (BigEndianBinaryReader vmgRead = new BigEndianBinaryReader(vmgFs)) + using (var vmgRead = new BigEndianBinaryReader(vmgFs)) { vmgFs.Seek(0x3E, SeekOrigin.Begin); _titleSetCount = vmgRead.ReadUInt16(); @@ -71,7 +71,7 @@ namespace DvdLib.Ifo read.BaseStream.Seek(6, SeekOrigin.Current); for (uint titleNum = 1; titleNum <= _titleCount; titleNum++) { - Title t = new Title(titleNum); + var t = new Title(titleNum); t.ParseTT_SRPT(read); Titles.Add(t); } @@ -98,7 +98,7 @@ namespace DvdLib.Ifo using (var vtsFs = _fileSystem.GetFileStream(vtsPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read)) { - using (BigEndianBinaryReader vtsRead = new BigEndianBinaryReader(vtsFs)) + using (var vtsRead = new BigEndianBinaryReader(vtsFs)) { // Read VTS_PTT_SRPT vtsFs.Seek(0xC8, SeekOrigin.Begin); @@ -119,7 +119,7 @@ namespace DvdLib.Ifo { uint chapNum = 1; vtsFs.Seek(baseAddr + offsets[titleNum], SeekOrigin.Begin); - Title t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum + 1)); + var t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum + 1)); if (t == null) continue; do @@ -149,7 +149,7 @@ namespace DvdLib.Ifo vtsFs.Seek(3, SeekOrigin.Current); uint vtsPgcOffset = vtsRead.ReadUInt32(); - Title t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum)); + var t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum)); if (t != null) t.AddPgc(vtsRead, startByte + vtsPgcOffset, entryPgc, pgcNum); } } diff --git a/DvdLib/Ifo/ProgramChain.cs b/DvdLib/Ifo/ProgramChain.cs index 0cdaad4cc..80889738f 100644 --- a/DvdLib/Ifo/ProgramChain.cs +++ b/DvdLib/Ifo/ProgramChain.cs @@ -87,7 +87,7 @@ namespace DvdLib.Ifo br.BaseStream.Seek(startPos + _cellPositionOffset, SeekOrigin.Begin); for (int cellNum = 0; cellNum < _cellCount; cellNum++) { - Cell c = new Cell(); + var c = new Cell(); c.ParsePosition(br); Cells.Add(c); } @@ -99,7 +99,7 @@ namespace DvdLib.Ifo } br.BaseStream.Seek(startPos + _programMapOffset, SeekOrigin.Begin); - List cellNumbers = new List(); + var cellNumbers = new List(); for (int progNum = 0; progNum < _programCount; progNum++) cellNumbers.Add(br.ReadByte() - 1); for (int i = 0; i < cellNumbers.Count; i++) diff --git a/DvdLib/Ifo/Title.cs b/DvdLib/Ifo/Title.cs index 85be9daf1..335e92992 100644 --- a/DvdLib/Ifo/Title.cs +++ b/DvdLib/Ifo/Title.cs @@ -50,7 +50,7 @@ namespace DvdLib.Ifo long curPos = br.BaseStream.Position; br.BaseStream.Seek(startByte, SeekOrigin.Begin); - ProgramChain pgc = new ProgramChain(pgcNum); + var pgc = new ProgramChain(pgcNum); pgc.ParseHeader(br); ProgramChains.Add(pgc); if (entryPgc) EntryProgramChain = pgc; diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index f4009ee93..01c9fe50f 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -241,7 +241,7 @@ namespace Emby.Dlna.Api var cacheLength = TimeSpan.FromDays(365); var cacheKey = Request.RawUrl.GetMD5(); - return _resultFactory.GetStaticResult(Request, cacheKey, null, cacheLength, contentType, () => Task.FromResult(_dlnaManager.GetIcon(request.Filename).Stream)); + return _resultFactory.GetStaticResult(Request, cacheKey, null, cacheLength, contentType, () => Task.FromResult(_dlnaManager.GetIcon(request.Filename).Stream)); } public object Subscribe(ProcessContentDirectoryEventRequest request) diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index 61ee45f74..5a8fd4068 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -242,7 +242,7 @@ namespace Emby.Dlna.ContentDirectory var dlnaOptions = _config.GetDlnaConfiguration(); - using (XmlWriter writer = XmlWriter.Create(builder, settings)) + using (var writer = XmlWriter.Create(builder, settings)) { //writer.WriteStartDocument(); @@ -358,7 +358,7 @@ namespace Emby.Dlna.ContentDirectory int totalCount = 0; int provided = 0; - using (XmlWriter writer = XmlWriter.Create(builder, settings)) + using (var writer = XmlWriter.Create(builder, settings)) { //writer.WriteStartDocument(); diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 6ecb9f3b4..d2f635e56 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -78,7 +78,7 @@ namespace Emby.Dlna.Didl using (StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8)) { - using (XmlWriter writer = XmlWriter.Create(builder, settings)) + using (var writer = XmlWriter.Create(builder, settings)) { //writer.WriteStartDocument(); diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index 95be02ff4..85a37d7f8 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -854,7 +854,7 @@ namespace Emby.Dlna.PlayTo if (index == -1) return request; var query = url.Substring(index + 1); - QueryParamCollection values = MyHttpUtility.ParseQueryString(query); + var values = MyHttpUtility.ParseQueryString(query); request.DeviceProfileId = values.Get("DeviceProfileId"); request.DeviceId = values.Get("DeviceId"); diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs index d65f8972b..5f78674b8 100644 --- a/Emby.Dlna/Service/BaseControlHandler.cs +++ b/Emby.Dlna/Service/BaseControlHandler.cs @@ -85,7 +85,7 @@ namespace Emby.Dlna.Service StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8); - using (XmlWriter writer = XmlWriter.Create(builder, settings)) + using (var writer = XmlWriter.Create(builder, settings)) { writer.WriteStartDocument(true); diff --git a/Emby.Dlna/Service/ControlErrorHandler.cs b/Emby.Dlna/Service/ControlErrorHandler.cs index e9c2c67b9..d5eb4a887 100644 --- a/Emby.Dlna/Service/ControlErrorHandler.cs +++ b/Emby.Dlna/Service/ControlErrorHandler.cs @@ -20,7 +20,7 @@ namespace Emby.Dlna.Service StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8); - using (XmlWriter writer = XmlWriter.Create(builder, settings)) + using (var writer = XmlWriter.Create(builder, settings)) { writer.WriteStartDocument(true); diff --git a/Emby.Drawing.Skia/StripCollageBuilder.cs b/Emby.Drawing.Skia/StripCollageBuilder.cs index 36d00669a..8d984de11 100644 --- a/Emby.Drawing.Skia/StripCollageBuilder.cs +++ b/Emby.Drawing.Skia/StripCollageBuilder.cs @@ -164,7 +164,7 @@ namespace Emby.Drawing.Skia private SKBitmap GetNextValidImage(string[] paths, int currentIndex, out int newIndex) { - Dictionary imagesTested = new Dictionary(); + var imagesTested = new Dictionary(); SKBitmap bitmap = null; while (imagesTested.Count < paths.Length) @@ -174,7 +174,7 @@ namespace Emby.Drawing.Skia currentIndex = 0; } - bitmap = SkiaEncoder.Decode(paths[currentIndex], false, _fileSystem, null, out SKEncodedOrigin origin); + bitmap = SkiaEncoder.Decode(paths[currentIndex], false, _fileSystem, null, out var origin); imagesTested[currentIndex] = 0; diff --git a/Emby.Drawing/Common/ImageHeader.cs b/Emby.Drawing/Common/ImageHeader.cs index 6b604bc15..3939a1664 100644 --- a/Emby.Drawing/Common/ImageHeader.cs +++ b/Emby.Drawing/Common/ImageHeader.cs @@ -73,7 +73,7 @@ namespace Emby.Drawing.Common /// /// The binary reader. /// Size. - /// binaryReader + /// binaryReader /// The image was of an unrecognized format. private static ImageSize GetDimensions(BinaryReader binaryReader) { @@ -200,7 +200,7 @@ namespace Emby.Drawing.Common /// /// The binary reader. /// Size. - /// + /// private static ImageSize DecodeJfif(BinaryReader binaryReader) { // A JPEG image consists of a sequence of segments, diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 57a6eb148..a88c720a7 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -491,7 +491,7 @@ namespace Emby.Drawing /// The item. /// The image. /// Guid. - /// item + /// item public string GetImageCacheTag(BaseItem item, ItemImageInfo image) { var supportedEnhancers = GetSupportedEnhancers(item, image.Type); @@ -523,7 +523,7 @@ namespace Emby.Drawing /// The image. /// The image enhancers. /// Guid. - /// item + /// item public string GetImageCacheTag(BaseItem item, ItemImageInfo image, IImageEnhancer[] imageEnhancers) { var originalImagePath = image.Path; @@ -744,7 +744,7 @@ namespace Emby.Drawing /// Name of the unique. /// The file extension. /// System.String. - /// + /// /// path /// or /// uniqueName @@ -778,7 +778,7 @@ namespace Emby.Drawing /// The path. /// The filename. /// System.String. - /// + /// /// path /// or /// filename diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs index ac486f167..4729b5b5a 100644 --- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs +++ b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs @@ -141,7 +141,7 @@ namespace IsoMounter public Task Mount(string isoPath, CancellationToken cancellationToken) { - if (MountISO(isoPath, out LinuxMount mountedISO)) + if (MountISO(isoPath, out var mountedISO)) { return Task.FromResult(mountedISO); } diff --git a/Emby.Naming/AudioBook/AudioBookFilePathParser.cs b/Emby.Naming/AudioBook/AudioBookFilePathParser.cs index 8c52fd9b9..b386593e7 100644 --- a/Emby.Naming/AudioBook/AudioBookFilePathParser.cs +++ b/Emby.Naming/AudioBook/AudioBookFilePathParser.cs @@ -16,7 +16,7 @@ namespace Emby.Naming.AudioBook public AudioBookFilePathParserResult Parse(string path, bool IsDirectory) { - AudioBookFilePathParserResult result = Parse(path); + var result = Parse(path); return !result.Success ? new AudioBookFilePathParserResult() : result; } diff --git a/Emby.Naming/TV/EpisodePathParser.cs b/Emby.Naming/TV/EpisodePathParser.cs index 76c59d38e..260cb505c 100644 --- a/Emby.Naming/TV/EpisodePathParser.cs +++ b/Emby.Naming/TV/EpisodePathParser.cs @@ -133,7 +133,7 @@ namespace Emby.Naming.TV result.EpisodeNumber = num; } - Group endingNumberGroup = match.Groups["endingepnumber"]; + var endingNumberGroup = match.Groups["endingepnumber"]; if (endingNumberGroup.Success) { // Will only set EndingEpsiodeNumber if the captured number is not followed by additional numbers diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs index de8f96965..9bd0cb3df 100644 --- a/Emby.Naming/Video/VideoResolver.cs +++ b/Emby.Naming/Video/VideoResolver.cs @@ -40,7 +40,7 @@ namespace Emby.Naming.Video /// The path. /// if set to true [is folder]. /// VideoFileInfo. - /// path + /// path public VideoFileInfo Resolve(string path, bool IsDirectory, bool parseName = true) { if (string.IsNullOrEmpty(path)) diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs index 90a0671f2..a8e8f815a 100644 --- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs +++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs @@ -527,7 +527,7 @@ namespace Emby.Server.Implementations.Activity const int DaysInMonth = 30; // Get each non-zero value from TimeSpan component - List values = new List(); + var values = new List(); // Number of years int days = span.Days; @@ -558,7 +558,7 @@ namespace Emby.Server.Implementations.Activity values.Add(CreateValueString(span.Seconds, "second")); // Combine values into string - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); for (int i = 0; i < values.Count; i++) { if (builder.Length > 0) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 6f393a03c..59c7c655f 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.AppBase /// Replaces the configuration. /// /// The new configuration. - /// newConfiguration + /// newConfiguration public virtual void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration) { if (newConfiguration == null) @@ -188,7 +188,7 @@ namespace Emby.Server.Implementations.AppBase /// Replaces the cache path. /// /// The new configuration. - /// + /// private void ValidateCachePath(BaseApplicationConfiguration newConfig) { var newPath = newConfig.CachePath; diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 61b88345f..5f3508441 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -822,7 +822,7 @@ namespace Emby.Server.Implementations RegisterSingleInstance(ServerConfigurationManager); IAssemblyInfo assemblyInfo = new AssemblyInfo(); - RegisterSingleInstance(assemblyInfo); + RegisterSingleInstance(assemblyInfo); LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory.CreateLogger("LocalizationManager"), assemblyInfo, new TextLocalizer()); StringExtensions.LocalizationManager = LocalizationManager; @@ -920,7 +920,7 @@ namespace Emby.Server.Implementations RegisterSingleInstance(CollectionManager); PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LoggerFactory.CreateLogger("PlaylistManager"), UserManager, ProviderManager); - RegisterSingleInstance(PlaylistManager); + RegisterSingleInstance(PlaylistManager); LiveTvManager = new LiveTvManager(this, HttpClient, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager, SecurityManager, () => ChannelManager); RegisterSingleInstance(LiveTvManager); @@ -938,7 +938,7 @@ namespace Emby.Server.Implementations RegisterMediaEncoder(assemblyInfo); - EncodingManager = new Emby.Server.Implementations.MediaEncoder.EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager); + EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager); RegisterSingleInstance(EncodingManager); var activityLogRepo = GetActivityLogRepository(); @@ -950,7 +950,7 @@ namespace Emby.Server.Implementations RegisterSingleInstance(new SessionContext(UserManager, authContext, SessionManager)); AuthService = new AuthService(UserManager, authContext, ServerConfigurationManager, SessionManager, NetworkManager); - RegisterSingleInstance(AuthService); + RegisterSingleInstance(AuthService); SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory.CreateLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory, TextEncoding); RegisterSingleInstance(SubtitleEncoder); @@ -1023,7 +1023,7 @@ namespace Emby.Server.Implementations { var arr = str.ToCharArray(); - arr = Array.FindAll(arr, (c => (char.IsLetterOrDigit(c) + arr = Array.FindAll(arr, (c => (char.IsLetterOrDigit(c) || char.IsWhiteSpace(c)))); var result = new string(arr); @@ -1057,7 +1057,7 @@ namespace Emby.Server.Implementations // Don't use an empty string password var password = string.IsNullOrWhiteSpace(info.Password) ? null : info.Password; - X509Certificate2 localCert = new X509Certificate2(certificateLocation, password); + var localCert = new X509Certificate2(certificateLocation, password); //localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA; if (!localCert.HasPrivateKey) { diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs index 55f40db8f..ab2e1c9a9 100644 --- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -119,7 +119,7 @@ namespace Emby.Server.Implementations.Configuration /// Replaces the configuration. /// /// The new configuration. - /// + /// public override void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration) { var newConfig = (ServerConfiguration)newConfiguration; @@ -137,7 +137,7 @@ namespace Emby.Server.Implementations.Configuration /// Validates the SSL certificate. /// /// The new configuration. - /// + /// private void ValidateSslCertificate(BaseApplicationConfiguration newConfig) { var serverConfig = (ServerConfiguration)newConfig; @@ -159,7 +159,7 @@ namespace Emby.Server.Implementations.Configuration /// Validates the metadata path. /// /// The new configuration. - /// + /// private void ValidateMetadataPath(ServerConfiguration newConfig) { var newPath = newConfig.MetadataPath; diff --git a/Emby.Server.Implementations/Data/ManagedConnection.cs b/Emby.Server.Implementations/Data/ManagedConnection.cs index 2f3dfc4d1..b8f1e581a 100644 --- a/Emby.Server.Implementations/Data/ManagedConnection.cs +++ b/Emby.Server.Implementations/Data/ManagedConnection.cs @@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Data public T RunInTransaction(Func action, TransactionMode mode) { - return db.RunInTransaction(action, mode); + return db.RunInTransaction(action, mode); } public IEnumerable> Query(string sql) diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 822573f20..9ed2b49e5 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.Data /// The client. /// The cancellation token. /// Task. - /// item + /// item public void SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken) { if (displayPreferences == null) @@ -131,7 +131,7 @@ namespace Emby.Server.Implementations.Data /// The user id. /// The cancellation token. /// Task. - /// item + /// item public void SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, CancellationToken cancellationToken) { if (displayPreferences == null) @@ -163,7 +163,7 @@ namespace Emby.Server.Implementations.Data /// The user id. /// The client. /// Task{DisplayPreferences}. - /// item + /// item public DisplayPreferences GetDisplayPreferences(string displayPreferencesId, Guid userId, string client) { if (string.IsNullOrEmpty(displayPreferencesId)) @@ -202,7 +202,7 @@ namespace Emby.Server.Implementations.Data /// /// The user id. /// Task{DisplayPreferences}. - /// item + /// item public IEnumerable GetAllDisplayPreferences(Guid userId) { var list = new List(); diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs index 5ff61d37c..edb73d2a1 100644 --- a/Emby.Server.Implementations/Data/SqliteExtensions.cs +++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs @@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Data /// Serializes to bytes. /// /// System.Byte[][]. - /// obj + /// obj public static byte[] SerializeToBytes(this IJsonSerializer json, object obj) { if (obj == null) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 325bad501..7e7271371 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -531,7 +531,7 @@ namespace Emby.Server.Implementations.Data /// /// The item. /// The cancellation token. - /// item + /// item public void SaveItem(BaseItem item, CancellationToken cancellationToken) { if (item == null) @@ -574,7 +574,7 @@ namespace Emby.Server.Implementations.Data /// /// The items. /// The cancellation token. - /// + /// /// items /// or /// cancellationToken @@ -1198,8 +1198,8 @@ namespace Emby.Server.Implementations.Data /// /// The id. /// BaseItem. - /// id - /// + /// id + /// public BaseItem RetrieveItem(Guid id) { if (id.Equals(Guid.Empty)) @@ -1945,7 +1945,7 @@ namespace Emby.Server.Implementations.Data /// /// The item. /// IEnumerable{ChapterInfo}. - /// id + /// id public List GetChapters(BaseItem item) { CheckDisposed(); @@ -1977,7 +1977,7 @@ namespace Emby.Server.Implementations.Data /// The item. /// The index. /// ChapterInfo. - /// id + /// id public ChapterInfo GetChapter(BaseItem item, int index) { CheckDisposed(); diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index 469927f63..48ff9ded8 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -110,7 +110,7 @@ namespace Emby.Server.Implementations.Data private List GetAllUserIdsWithUserData(IDatabaseConnection db) { - List list = new List(); + var list = new List(); using (var statement = PrepareStatement(db, "select DISTINCT UserId from UserData where UserId not null")) { @@ -271,7 +271,7 @@ namespace Emby.Server.Implementations.Data /// The user id. /// The key. /// Task{UserItemData}. - /// + /// /// userId /// or /// key diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs index bf00f2e65..ad37a0275 100644 --- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs @@ -200,7 +200,7 @@ namespace Emby.Server.Implementations.Data /// /// The user. /// Task. - /// user + /// user public void DeleteUser(User user) { if (user == null) diff --git a/Emby.Server.Implementations/Data/TypeMapper.cs b/Emby.Server.Implementations/Data/TypeMapper.cs index fa6a29aa3..37c952e88 100644 --- a/Emby.Server.Implementations/Data/TypeMapper.cs +++ b/Emby.Server.Implementations/Data/TypeMapper.cs @@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Data /// /// Name of the type. /// Type. - /// + /// public Type GetType(string typeName) { if (string.IsNullOrEmpty(typeName)) diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 68bff962f..8877fc051 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.Dto /// The user. /// The owner. /// Task{DtoBaseItem}. - /// item + /// item public BaseItemDto GetBaseItemDto(BaseItem item, ItemFields[] fields, User user = null, BaseItem owner = null) { var options = new DtoOptions @@ -463,7 +463,7 @@ namespace Emby.Server.Implementations.Dto /// /// The item. /// System.String. - /// item + /// item public string GetDtoId(BaseItem item) { return item.Id.ToString("N"); diff --git a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs index c7bd03960..e37ea96a1 100644 --- a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs @@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.EntryPoints try { - await _sessionManager.SendMessageToUserSessions(users, name, info, CancellationToken.None); + await _sessionManager.SendMessageToUserSessions(users, name, info, CancellationToken.None); } catch (ObjectDisposedException) { diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index 72828f0d4..255e1476f 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -82,7 +82,7 @@ namespace Emby.Server.Implementations.HttpClientManager /// The host. /// if set to true [enable HTTP compression]. /// HttpClient. - /// host + /// host private HttpClientInfo GetHttpClient(string host, bool enableHttpCompression) { if (string.IsNullOrEmpty(host)) @@ -125,7 +125,7 @@ namespace Emby.Server.Implementations.HttpClientManager { string url = options.Url; - Uri uriAddress = new Uri(url); + var uriAddress = new Uri(url); string userInfo = uriAddress.UserInfo; if (!string.IsNullOrWhiteSpace(userInfo)) { @@ -133,7 +133,7 @@ namespace Emby.Server.Implementations.HttpClientManager url = url.Replace(userInfo + "@", string.Empty); } - WebRequest request = CreateWebRequest(url); + var request = CreateWebRequest(url); if (request is HttpWebRequest httpWebRequest) { @@ -188,7 +188,7 @@ namespace Emby.Server.Implementations.HttpClientManager private static CredentialCache GetCredential(string url, string username, string password) { //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; - CredentialCache credentialCache = new CredentialCache(); + var credentialCache = new CredentialCache(); credentialCache.Add(new Uri(url), "Basic", new NetworkCredential(username, password)); return credentialCache; } @@ -807,7 +807,7 @@ namespace Emby.Server.Implementations.HttpClientManager { var taskCompletion = new TaskCompletionSource(); - Task asyncTask = Task.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null); + var asyncTask = Task.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null); ThreadPool.RegisterWaitForSingleObject((asyncTask as IAsyncResult).AsyncWaitHandle, TimeoutCallback, request, timeout, true); var callback = new TaskCallback { taskCompletion = taskCompletion }; @@ -823,7 +823,7 @@ namespace Emby.Server.Implementations.HttpClientManager { if (timedOut && state != null) { - WebRequest request = (WebRequest)state; + var request = (WebRequest)state; request.Abort(); } } diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index 1ad92a83f..b9146d007 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.HttpServer /// The remote end point. /// The json serializer. /// The logger. - /// socket + /// socket public WebSocketConnection(IWebSocket socket, string remoteEndPoint, IJsonSerializer jsonSerializer, ILogger logger, ITextEncoding textEncoding) { if (socket == null) @@ -215,7 +215,7 @@ namespace Emby.Server.Implementations.HttpServer /// The message. /// The cancellation token. /// Task. - /// message + /// message public Task SendAsync(WebSocketMessage message, CancellationToken cancellationToken) { if (message == null) diff --git a/Emby.Server.Implementations/IO/IsoManager.cs b/Emby.Server.Implementations/IO/IsoManager.cs index e82335d65..f0a15097c 100644 --- a/Emby.Server.Implementations/IO/IsoManager.cs +++ b/Emby.Server.Implementations/IO/IsoManager.cs @@ -23,8 +23,8 @@ namespace Emby.Server.Implementations.IO /// The iso path. /// The cancellation token. /// IsoMount. - /// isoPath - /// + /// isoPath + /// public Task Mount(string isoPath, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(isoPath)) diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index 39ed1afa7..2c92e6543 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -263,7 +263,7 @@ namespace Emby.Server.Implementations.IO /// The LST. /// The path. /// true if [contains parent folder] [the specified LST]; otherwise, false. - /// path + /// path private static bool ContainsParentFolder(IEnumerable lst, string path) { if (string.IsNullOrEmpty(path)) diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index 7574eb0e9..ae1470190 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.IO /// /// The filename. /// true if the specified filename is shortcut; otherwise, false. - /// filename + /// filename public virtual bool IsShortcut(string filename) { if (string.IsNullOrEmpty(filename)) @@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.IO /// /// The filename. /// System.String. - /// filename + /// filename public virtual string ResolveShortcut(string filename) { if (string.IsNullOrEmpty(filename)) @@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.IO /// /// The shortcut path. /// The target. - /// + /// /// shortcutPath /// or /// target @@ -344,7 +344,7 @@ namespace Emby.Server.Implementations.IO /// /// The filename. /// System.String. - /// filename + /// filename public string GetValidFilename(string filename) { var builder = new StringBuilder(filename); @@ -526,7 +526,7 @@ namespace Emby.Server.Implementations.IO } else { - FileAttributes attributes = File.GetAttributes(path); + var attributes = File.GetAttributes(path); attributes = RemoveAttribute(attributes, FileAttributes.Hidden); File.SetAttributes(path, attributes); } @@ -550,7 +550,7 @@ namespace Emby.Server.Implementations.IO } else { - FileAttributes attributes = File.GetAttributes(path); + var attributes = File.GetAttributes(path); attributes = RemoveAttribute(attributes, FileAttributes.ReadOnly); File.SetAttributes(path, attributes); } diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 9c2759f13..0d25cbc92 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -711,7 +711,7 @@ namespace Emby.Server.Implementations.Library /// Creates the root media folder /// /// AggregateFolder. - /// Cannot create the root folder until plugins have loaded + /// Cannot create the root folder until plugins have loaded public AggregateFolder CreateRootFolder() { var rootFolderPath = ConfigurationManager.ApplicationPaths.RootFolderPath; @@ -905,7 +905,7 @@ namespace Emby.Server.Implementations.Library /// /// The value. /// Task{Year}. - /// + /// public Year GetYear(int value) { if (value <= 0) @@ -1233,7 +1233,7 @@ namespace Emby.Server.Implementations.Library /// /// The id. /// BaseItem. - /// id + /// id public BaseItem GetItemById(Guid id) { if (id.Equals(Guid.Empty)) @@ -2075,7 +2075,7 @@ namespace Emby.Server.Implementations.Library public string GetConfiguredContentType(BaseItem item, bool inheritConfiguredPath) { - ICollectionFolder collectionFolder = item as ICollectionFolder; + var collectionFolder = item as ICollectionFolder; if (collectionFolder != null) { return collectionFolder.CollectionType; @@ -2417,11 +2417,11 @@ namespace Emby.Server.Implementations.Library var episodeInfo = episode.IsFileProtocol ? resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming) : - new Emby.Naming.TV.EpisodeInfo(); + new Naming.TV.EpisodeInfo(); if (episodeInfo == null) { - episodeInfo = new Emby.Naming.TV.EpisodeInfo(); + episodeInfo = new Naming.TV.EpisodeInfo(); } var changed = false; diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index dcda95742..fb0f33a2f 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -127,7 +127,7 @@ namespace Emby.Server.Implementations.Library if (allowMediaProbe && mediaSources[0].Type != MediaSourceType.Placeholder && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Audio || i.Type == MediaStreamType.Video)) { - await item.RefreshMetadata(new MediaBrowser.Controller.Providers.MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem)) + await item.RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem)) { EnableRemoteContentProbe = true, MetadataRefreshMode = MediaBrowser.Controller.Providers.MetadataRefreshMode.FullRefresh diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs index 6a3adda5a..d3a81f622 100644 --- a/Emby.Server.Implementations/Library/PathExtensions.cs +++ b/Emby.Server.Implementations/Library/PathExtensions.cs @@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.Library /// The STR. /// The attrib. /// System.String. - /// attrib + /// attrib public static string GetAttributeValue(this string str, string attrib) { if (string.IsNullOrEmpty(str)) diff --git a/Emby.Server.Implementations/Library/ResolverHelper.cs b/Emby.Server.Implementations/Library/ResolverHelper.cs index 7484fc743..96d1bff92 100644 --- a/Emby.Server.Implementations/Library/ResolverHelper.cs +++ b/Emby.Server.Implementations/Library/ResolverHelper.cs @@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.Library /// The file system. /// The library manager. /// The directory service. - /// Item must have a path + /// Item must have a path public static void SetInitialItemValues(BaseItem item, Folder parent, IFileSystem fileSystem, ILibraryManager libraryManager, IDirectoryService directoryService) { // This version of the below method has no ItemResolveArgs, so we have to require the path already being set diff --git a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs index bd5132c4b..d992f8d03 100644 --- a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs @@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.Library.Resolvers var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); // If the path is a file check for a matching extensions - var parser = new Emby.Naming.Video.VideoResolver(namingOptions); + var parser = new VideoResolver(namingOptions); if (args.IsDirectory) { diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs index a806c842f..ce1386e91 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs @@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV if (!season.IndexNumber.HasValue || !seasonParserResult.IsSeasonFolder) { - var resolver = new Emby.Naming.TV.EpisodeResolver(namingOptions); + var resolver = new Naming.TV.EpisodeResolver(namingOptions); var folderName = System.IO.Path.GetFileName(path); var testPath = "\\\\test\\" + folderName; diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs index 3bd5b78a5..16b5a2d3a 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs @@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV var namingOptions = ((LibraryManager)libraryManager).GetNamingOptions(); - var episodeResolver = new Emby.Naming.TV.EpisodeResolver(namingOptions); + var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions); bool? isNamed = null; bool? isOptimistic = null; @@ -179,7 +179,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV /// /// The path. /// true if [is place holder] [the specified path]; otherwise, false. - /// path + /// path private static bool IsVideoPlaceHolder(string path) { if (string.IsNullOrEmpty(path)) diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs index 06f76311c..71638b197 100644 --- a/Emby.Server.Implementations/Library/SearchEngine.cs +++ b/Emby.Server.Implementations/Library/SearchEngine.cs @@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Library /// The query. /// The user. /// IEnumerable{SearchHintResult}. - /// searchTerm + /// searchTerm private List GetSearchHints(SearchQuery query, User user) { var searchTerm = query.SearchTerm; diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index f2921e354..dfa1edaff 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -193,7 +193,7 @@ namespace Emby.Server.Implementations.Library /// /// The data. /// DtoUserItemData. - /// + /// private UserItemDataDto GetUserItemDataDto(UserItemData data) { if (data == null) diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index e4c9f775e..f06c71386 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -158,7 +158,7 @@ namespace Emby.Server.Implementations.Library /// /// The id. /// User. - /// + /// public User GetUserById(Guid id) { if (id.Equals(Guid.Empty)) @@ -619,8 +619,8 @@ namespace Emby.Server.Implementations.Library /// The user. /// The new name. /// Task. - /// user - /// + /// user + /// public async Task RenameUser(User user, string newName) { if (user == null) @@ -652,8 +652,8 @@ namespace Emby.Server.Implementations.Library /// Updates the user. /// /// The user. - /// user - /// + /// user + /// public void UpdateUser(User user) { if (user == null) @@ -683,8 +683,8 @@ namespace Emby.Server.Implementations.Library /// /// The name. /// User. - /// name - /// + /// name + /// public async Task CreateUser(string name) { if (string.IsNullOrWhiteSpace(name)) @@ -731,8 +731,8 @@ namespace Emby.Server.Implementations.Library /// /// The user. /// Task. - /// user - /// + /// user + /// public async Task DeleteUser(User user) { if (user == null) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 909e6eaee..0ee53281d 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -478,7 +478,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private static string GetMappedChannel(string channelId, NameValuePair[] mappings) { - foreach (NameValuePair mapping in mappings) + foreach (var mapping in mappings) { if (StringHelper.EqualsIgnoreCase(mapping.Name, channelId)) { @@ -2002,7 +2002,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV CloseOutput = false }; - using (XmlWriter writer = XmlWriter.Create(stream, settings)) + using (var writer = XmlWriter.Create(stream, settings)) { writer.WriteStartDocument(true); writer.WriteStartElement("tvshow"); @@ -2069,7 +2069,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var isSeriesEpisode = timer.IsProgramSeries; - using (XmlWriter writer = XmlWriter.Create(stream, settings)) + using (var writer = XmlWriter.Create(stream, settings)) { writer.WriteStartDocument(true); diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 25ad02e5d..05d92dfcb 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings private static List GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc) { - List dates = new List(); + var dates = new List(); var start = new List { startDateUtc, startDateUtc.ToLocalTime() }.Min().Date; var end = new List { endDateUtc, endDateUtc.ToLocalTime() }.Max().Date; @@ -104,7 +104,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings httpOptions.RequestHeaders["token"] = token; using (var response = await Post(httpOptions, true, info).ConfigureAwait(false)) - using (StreamReader reader = new StreamReader(response.Content)) + using (var reader = new StreamReader(response.Content)) { var dailySchedules = await _jsonSerializer.DeserializeFromStreamAsync>(response.Content).ConfigureAwait(false); _logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId); @@ -125,7 +125,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings httpOptions.RequestContent = "[\"" + string.Join("\", \"", programsID) + "\"]"; using (var innerResponse = await Post(httpOptions, true, info).ConfigureAwait(false)) - using (StreamReader innerReader = new StreamReader(innerResponse.Content)) + using (var innerReader = new StreamReader(innerResponse.Content)) { var programDetails = await _jsonSerializer.DeserializeFromStreamAsync>(innerResponse.Content).ConfigureAwait(false); var programDict = programDetails.ToDictionary(p => p.programID, y => y); @@ -136,8 +136,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings var images = await GetImageForPrograms(info, programIdsWithImages, cancellationToken).ConfigureAwait(false); - List programsInfo = new List(); - foreach (ScheduleDirect.Program schedule in dailySchedules.SelectMany(d => d.programs)) + var programsInfo = new List(); + foreach (var schedule in dailySchedules.SelectMany(d => d.programs)) { //_logger.LogDebug("Proccesing Schedule for statio ID " + stationID + // " which corresponds to channel " + channelNumber + " and program id " + @@ -222,9 +222,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings private ProgramInfo GetProgram(string channelId, ScheduleDirect.Program programInfo, ScheduleDirect.ProgramDetails details) { - DateTime startAt = GetDate(programInfo.airDateTime); - DateTime endAt = startAt.AddSeconds(programInfo.duration); - ProgramAudio audioType = ProgramAudio.Stereo; + var startAt = GetDate(programInfo.airDateTime); + var endAt = startAt.AddSeconds(programInfo.duration); + var audioType = ProgramAudio.Stereo; var programId = programInfo.programID ?? string.Empty; @@ -526,15 +526,15 @@ namespace Emby.Server.Implementations.LiveTv.Listings try { using (var httpResponse = await Get(options, false, info).ConfigureAwait(false)) - using (Stream responce = httpResponse.Content) + using (var responce = httpResponse.Content) { var root = await _jsonSerializer.DeserializeFromStreamAsync>(responce).ConfigureAwait(false); if (root != null) { - foreach (ScheduleDirect.Headends headend in root) + foreach (var headend in root) { - foreach (ScheduleDirect.Lineup lineup in headend.lineups) + foreach (var lineup in headend.lineups) { lineups.Add(new NameIdPair { @@ -887,7 +887,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings var allStations = root.stations ?? Enumerable.Empty(); - foreach (ScheduleDirect.Map map in root.map) + foreach (var map in root.map) { var channelNumber = GetChannelNumber(map); diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 2b1ee84a8..0cbfbe0b4 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -269,7 +269,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings string path = await GetXml(info.Path, CancellationToken.None).ConfigureAwait(false); _logger.LogDebug("Opening XmlTvReader for {path}", path); var reader = new XmlTvReader(path, GetLanguage(info)); - IEnumerable results = reader.GetChannels(); + var results = reader.GetChannels(); // Should this method be async? return results.Select(c => new NameIdPair() { Id = c.Id, Name = c.DisplayName }).ToList(); @@ -281,7 +281,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings string path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false); _logger.LogDebug("Opening XmlTvReader for {path}", path); var reader = new XmlTvReader(path, GetLanguage(info)); - IEnumerable results = reader.GetChannels(); + var results = reader.GetChannels(); // Should this method be async? return results.Select(c => new ChannelInfo diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 4ad58c7e4..379927191 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -242,7 +242,7 @@ namespace Emby.Server.Implementations.LiveTv var channel = (LiveTvChannel)_libraryManager.GetItemById(id); bool isVideo = channel.ChannelType == ChannelType.TV; - ILiveTvService service = GetService(channel); + var service = GetService(channel); _logger.LogInformation("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId); MediaSourceInfo info; @@ -892,7 +892,7 @@ namespace Emby.Server.Implementations.LiveTv var programList = _libraryManager.QueryItems(internalQuery).Items; var totalCount = programList.Length; - IOrderedEnumerable orderedPrograms = programList.Cast().OrderBy(i => i.StartDate.Date); + var orderedPrograms = programList.Cast().OrderBy(i => i.StartDate.Date); if (query.IsAiring ?? false) { @@ -2302,7 +2302,7 @@ namespace Emby.Server.Implementations.LiveTv // ServerConfiguration.SaveConfiguration crashes during xml serialization for AddListingProvider info = _jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info)); - IListingsProvider provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); + var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); if (provider == null) { @@ -2313,9 +2313,9 @@ namespace Emby.Server.Implementations.LiveTv await provider.Validate(info, validateLogin, validateListings).ConfigureAwait(false); - LiveTvOptions config = GetConfiguration(); + var config = GetConfiguration(); - List list = config.ListingProviders.ToList(); + var list = config.ListingProviders.ToList(); int index = list.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase)); if (index == -1 || string.IsNullOrWhiteSpace(info.Id)) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 3714a0321..36f688c43 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -262,7 +262,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var name = string.Format("Tuner {0}", i + 1); var currentChannel = "none"; /// @todo Get current channel and map back to Station Id var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false); - LiveTvTunerStatus status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv; + var status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv; tuners.Add(new LiveTvTunerInfo { Name = name, diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs index 1ec5894d0..67eeec21d 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs @@ -173,7 +173,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun continue; var commandList = commands.GetCommands(); - foreach (Tuple command in commandList) + foreach (var command in commandList) { var channelMsg = CreateSetMessage(i, command.Item1, command.Item2, lockKeyValue); await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false); @@ -216,7 +216,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var commandList = commands.GetCommands(); var receiveBuffer = new byte[8192]; - foreach (Tuple command in commandList) + foreach (var command in commandList) { var channelMsg = CreateSetMessage(_activeTuner, command.Item1, command.Item2, _lockkey); await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), cancellationToken).ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs b/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs index 9d880b0c9..304b44565 100644 --- a/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs +++ b/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs @@ -19,10 +19,10 @@ namespace Emby.Server.Implementations.Net //TODO Remove and reimplement using the IsDisposed property directly. /// - /// Throws an if the property is true. + /// Throws an if the property is true. /// /// - /// Thrown if the property is true. + /// Thrown if the property is true. /// protected virtual void ThrowIfDisposed() { diff --git a/Emby.Server.Implementations/Net/UdpSocket.cs b/Emby.Server.Implementations/Net/UdpSocket.cs index cdfdb7210..d48855486 100644 --- a/Emby.Server.Implementations/Net/UdpSocket.cs +++ b/Emby.Server.Implementations/Net/UdpSocket.cs @@ -133,8 +133,8 @@ namespace Emby.Server.Implementations.Net { ThrowIfDisposed(); - IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0); - EndPoint remoteEndPoint = (EndPoint)sender; + var sender = new IPEndPoint(IPAddress.Any, 0); + var remoteEndPoint = (EndPoint)sender; var receivedBytes = _Socket.EndReceiveFrom(result, ref remoteEndPoint); diff --git a/Emby.Server.Implementations/Networking/IPNetwork/BigIntegerExt.cs b/Emby.Server.Implementations/Networking/IPNetwork/BigIntegerExt.cs index 1a2ad665b..447cbf403 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/BigIntegerExt.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/BigIntegerExt.cs @@ -7,7 +7,7 @@ namespace System.Net using System.Text; /// - /// Extension methods to convert + /// Extension methods to convert /// instances to hexadecimal, octal, and binary strings. /// public static class BigIntegerExtensions @@ -17,7 +17,7 @@ namespace System.Net /// /// A . /// - /// A containing a binary + /// A containing a binary /// representation of the supplied . /// public static string ToBinaryString(this BigInteger bigint) @@ -54,7 +54,7 @@ namespace System.Net /// /// A . /// - /// A containing a hexadecimal + /// A containing a hexadecimal /// representation of the supplied . /// public static string ToHexadecimalString(this BigInteger bigint) @@ -67,7 +67,7 @@ namespace System.Net /// /// A . /// - /// A containing an octal + /// A containing an octal /// representation of the supplied . /// public static string ToOctalString(this BigInteger bigint) diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs index c2a6305f6..c5853135c 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs @@ -30,7 +30,7 @@ namespace System.Net throw new ArgumentOutOfRangeException(nameof(i)); } byte width = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetwork ? (byte)32 : (byte)128; - IPNetworkCollection ipn = this._ipnetwork.Subnet(width); + var ipn = this._ipnetwork.Subnet(width); return ipn[i].Network; } } diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs index 321d4a3c5..21feaea33 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs @@ -33,7 +33,7 @@ namespace System.Net { get { - BigInteger uintNetwork = this._ipaddress & this._netmask; + var uintNetwork = this._ipaddress & this._netmask; return uintNetwork; } } @@ -61,7 +61,7 @@ namespace System.Net { int width = this._family == Sockets.AddressFamily.InterNetwork ? 4 : 16; - BigInteger uintBroadcast = this._network + this._netmask.PositiveReverse(width); + var uintBroadcast = this._network + this._netmask.PositiveReverse(width); return uintBroadcast; } } @@ -88,7 +88,7 @@ namespace System.Net { get { - BigInteger fisrt = this._family == Sockets.AddressFamily.InterNetworkV6 + var fisrt = this._family == Sockets.AddressFamily.InterNetworkV6 ? this._network : (this.Usable <= 0) ? this._network : this._network + 1; return IPNetwork.ToIPAddress(fisrt, this._family); @@ -102,7 +102,7 @@ namespace System.Net { get { - BigInteger last = this._family == Sockets.AddressFamily.InterNetworkV6 + var last = this._family == Sockets.AddressFamily.InterNetworkV6 ? this._broadcast : (this.Usable <= 0) ? this._network : this._broadcast - 1; return IPNetwork.ToIPAddress(last, this._family); @@ -122,8 +122,8 @@ namespace System.Net return this.Total; } byte[] mask = new byte[] { 0xff, 0xff, 0xff, 0xff, 0x00 }; - BigInteger bmask = new BigInteger(mask); - BigInteger usableIps = (_cidr > 30) ? 0 : ((bmask >> _cidr) - 1); + var bmask = new BigInteger(mask); + var usableIps = (_cidr > 30) ? 0 : ((bmask >> _cidr) - 1); return usableIps; } } @@ -137,7 +137,7 @@ namespace System.Net { int max = this._family == Sockets.AddressFamily.InterNetwork ? 32 : 128; - BigInteger count = BigInteger.Pow(2, (max - _cidr)); + var count = BigInteger.Pow(2, (max - _cidr)); return count; } } @@ -523,7 +523,7 @@ namespace System.Net return; } - BigInteger uintIpAddress = IPNetwork.ToBigInteger(ipaddress); + var uintIpAddress = IPNetwork.ToBigInteger(ipaddress); byte? cidr2 = null; bool parsed = IPNetwork.TryToCidr(netmask, out cidr2); if (parsed == false) @@ -537,7 +537,7 @@ namespace System.Net } byte cidr = (byte)cidr2; - IPNetwork ipnet = new IPNetwork(uintIpAddress, ipaddress.AddressFamily, cidr); + var ipnet = new IPNetwork(uintIpAddress, ipaddress.AddressFamily, cidr); ipnetwork = ipnet; return; @@ -754,7 +754,7 @@ namespace System.Net return; } - BigInteger mask = new BigInteger(new byte[] { + var mask = new BigInteger(new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -762,7 +762,7 @@ namespace System.Net 0x00 }); - BigInteger masked = cidr == 0 ? 0 : mask << (128 - cidr); + var masked = cidr == 0 ? 0 : mask << (128 - cidr); byte[] m = masked.ToByteArray(); byte[] bmask = new byte[17]; int copy = m.Length > 16 ? 16 : m.Length; @@ -858,7 +858,7 @@ namespace System.Net /// cidr = null; /// return; /// } - BigInteger uintNetmask = (BigInteger)uintNetmask2; + var uintNetmask = (BigInteger)uintNetmask2; byte? cidr2 = null; IPNetwork.InternalToCidr(tryParse, uintNetmask, netmask.AddressFamily, out cidr2); @@ -951,8 +951,8 @@ namespace System.Net return; } - BigInteger mask = IPNetwork.ToUint(cidr, family); - IPAddress netmask2 = IPNetwork.ToIPAddress(mask, family); + var mask = IPNetwork.ToUint(cidr, family); + var netmask2 = IPNetwork.ToIPAddress(mask, family); netmask = netmask2; return; @@ -990,7 +990,7 @@ namespace System.Net /// public static uint BitsSet(IPAddress netmask) { - BigInteger uintNetmask = IPNetwork.ToBigInteger(netmask); + var uintNetmask = IPNetwork.ToBigInteger(netmask); uint bits = IPNetwork.BitsSet(uintNetmask, netmask.AddressFamily); return bits; } @@ -1013,7 +1013,7 @@ namespace System.Net { throw new ArgumentNullException(nameof(netmask)); } - BigInteger uintNetmask = IPNetwork.ToBigInteger(netmask); + var uintNetmask = IPNetwork.ToBigInteger(netmask); bool valid = IPNetwork.InternalValidNetmask(uintNetmask, netmask.AddressFamily); return valid; } @@ -1042,7 +1042,7 @@ namespace System.Net 0x00 }); - BigInteger neg = ((~netmask) & (mask)); + var neg = ((~netmask) & (mask)); bool isNetmask = ((neg + 1) & neg) == 0; return isNetmask; @@ -1068,7 +1068,7 @@ namespace System.Net Array.Reverse(bytes2); byte[] sized = Resize(bytes2, family); - IPAddress ip = new IPAddress(sized); + var ip = new IPAddress(sized); return ip; } @@ -1122,9 +1122,9 @@ namespace System.Net return false; } - BigInteger uintNetwork = _network; - BigInteger uintBroadcast = _broadcast; - BigInteger uintAddress = IPNetwork.ToBigInteger(ipaddress); + var uintNetwork = _network; + var uintBroadcast = _broadcast; + var uintAddress = IPNetwork.ToBigInteger(ipaddress); bool contains = (uintAddress >= uintNetwork && uintAddress <= uintBroadcast); @@ -1146,11 +1146,11 @@ namespace System.Net throw new ArgumentNullException(nameof(network2)); } - BigInteger uintNetwork = _network; - BigInteger uintBroadcast = _broadcast; + var uintNetwork = _network; + var uintBroadcast = _broadcast; - BigInteger uintFirst = network2._network; - BigInteger uintLast = network2._broadcast; + var uintFirst = network2._network; + var uintLast = network2._broadcast; bool contains = (uintFirst >= uintNetwork && uintLast <= uintBroadcast); @@ -1175,11 +1175,11 @@ namespace System.Net throw new ArgumentNullException(nameof(network2)); } - BigInteger uintNetwork = _network; - BigInteger uintBroadcast = _broadcast; + var uintNetwork = _network; + var uintBroadcast = _broadcast; - BigInteger uintFirst = network2._network; - BigInteger uintLast = network2._broadcast; + var uintFirst = network2._network; + var uintLast = network2._broadcast; bool overlap = (uintFirst >= uintNetwork && uintFirst <= uintBroadcast) @@ -1428,8 +1428,8 @@ namespace System.Net return; } - IPNetwork first = (network1._network < network2._network) ? network1 : network2; - IPNetwork last = (network1._network > network2._network) ? network1 : network2; + var first = (network1._network < network2._network) ? network1 : network2; + var last = (network1._network > network2._network) ? network1 : network2; /// Starting from here : /// network1 and network2 have the same cidr, @@ -1449,10 +1449,10 @@ namespace System.Net return; } - BigInteger uintSupernet = first._network; + var uintSupernet = first._network; byte cidrSupernet = (byte)(first._cidr - 1); - IPNetwork networkSupernet = new IPNetwork(uintSupernet, first._family, cidrSupernet); + var networkSupernet = new IPNetwork(uintSupernet, first._family, cidrSupernet); if (networkSupernet._network != first._network) { if (trySupernet == false) @@ -1535,9 +1535,9 @@ namespace System.Net return true; } - List supernetted = new List(); - List ipns = IPNetwork.Array2List(ipnetworks); - Stack current = IPNetwork.List2Stack(ipns); + var supernetted = new List(); + var ipns = IPNetwork.Array2List(ipnetworks); + var current = IPNetwork.List2Stack(ipns); int previousCount = 0; int currentCount = current.Count; @@ -1547,8 +1547,8 @@ namespace System.Net supernetted.Clear(); while (current.Count > 1) { - IPNetwork ipn1 = current.Pop(); - IPNetwork ipn2 = current.Peek(); + var ipn1 = current.Pop(); + var ipn2 = current.Peek(); IPNetwork outNetwork = null; bool success = ipn1.TrySupernet(ipn2, out outNetwork); @@ -1578,7 +1578,7 @@ namespace System.Net private static Stack List2Stack(List list) { - Stack stack = new Stack(); + var stack = new Stack(); list.ForEach(new Action( delegate (IPNetwork ipn) { @@ -1590,7 +1590,7 @@ namespace System.Net private static List Array2List(IPNetwork[] array) { - List ipns = new List(); + var ipns = new List(); ipns.AddRange(array); IPNetwork.RemoveNull(ipns); ipns.Sort(new Comparison( @@ -1659,10 +1659,10 @@ namespace System.Net throw new NotSupportedException("MixedAddressFamily"); } - IPNetwork ipnetwork = new IPNetwork(0, startIP.AddressFamily, 0); + var ipnetwork = new IPNetwork(0, startIP.AddressFamily, 0); for (byte cidr = 32; cidr >= 0; cidr--) { - IPNetwork wideSubnet = IPNetwork.Parse(start, cidr); + var wideSubnet = IPNetwork.Parse(start, cidr); if (wideSubnet.Contains(endIP)) { ipnetwork = wideSubnet; @@ -1707,7 +1707,7 @@ namespace System.Net } - IPNetwork[] nnin = Array.FindAll(ipnetworks, new Predicate( + IPNetwork[] nnin = Array.FindAll(ipnetworks, new Predicate( delegate (IPNetwork ipnet) { return ipnet != null; @@ -1726,19 +1726,19 @@ namespace System.Net if (nnin.Length == 1) { - IPNetwork ipn0 = nnin[0]; + var ipn0 = nnin[0]; ipnetwork = ipn0; return; } - Array.Sort(nnin); - IPNetwork nnin0 = nnin[0]; - BigInteger uintNnin0 = nnin0._ipaddress; + Array.Sort(nnin); + var nnin0 = nnin[0]; + var uintNnin0 = nnin0._ipaddress; - IPNetwork nninX = nnin[nnin.Length - 1]; - IPAddress ipaddressX = nninX.Broadcast; + var nninX = nnin[nnin.Length - 1]; + var ipaddressX = nninX.Broadcast; - AddressFamily family = ipnetworks[0]._family; + var family = ipnetworks[0]._family; foreach (var ipnx in ipnetworks) { if (ipnx._family != family) @@ -1747,10 +1747,10 @@ namespace System.Net } } - IPNetwork ipn = new IPNetwork(0, family, 0); + var ipn = new IPNetwork(0, family, 0); for (byte cidr = nnin0._cidr; cidr >= 0; cidr--) { - IPNetwork wideSubnet = new IPNetwork(uintNnin0, family, cidr); + var wideSubnet = new IPNetwork(uintNnin0, family, cidr); if (wideSubnet.Contains(ipaddressX)) { ipn = wideSubnet; @@ -1773,7 +1773,7 @@ namespace System.Net public string Print() { - StringWriter sw = new StringWriter(); + var sw = new StringWriter(); sw.WriteLine("IPNetwork : {0}", ToString()); sw.WriteLine("Network : {0}", Network); @@ -1819,7 +1819,7 @@ namespace System.Net cidr = 64; return true; } - BigInteger uintIPAddress = IPNetwork.ToBigInteger(ipaddress); + var uintIPAddress = IPNetwork.ToBigInteger(ipaddress); uintIPAddress = uintIPAddress >> 29; if (uintIPAddress <= 3) { diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs index 1827af77a..7d3106624 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs @@ -47,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; } } @@ -61,11 +61,11 @@ namespace System.Net 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; } } diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs index 568981abb..70d8376a9 100644 --- a/Emby.Server.Implementations/Networking/NetworkManager.cs +++ b/Emby.Server.Implementations/Networking/NetworkManager.cs @@ -214,9 +214,9 @@ namespace Emby.Server.Implementations.Networking subnets = new List(); - foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces()) + foreach (var adapter in NetworkInterface.GetAllNetworkInterfaces()) { - foreach (UnicastIPAddressInformation unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses) + foreach (var unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses) { if (unicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork && endpointFirstPart == unicastIPAddressInformation.Address.ToString().Split('.')[0]) { @@ -461,7 +461,7 @@ namespace Emby.Server.Implementations.Networking public int GetRandomUnusedUdpPort() { - IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 0); + var localEndPoint = new IPEndPoint(IPAddress.Any, 0); using (var udpClient = new UdpClient(localEndPoint)) { var port = ((IPEndPoint)(udpClient.Client.LocalEndPoint)).Port; @@ -522,8 +522,8 @@ namespace Emby.Server.Implementations.Networking /// The endpointstring. /// The defaultport. /// IPEndPoint. - /// Endpoint descriptor may not be empty. - /// + /// Endpoint descriptor may not be empty. + /// private static async Task Parse(string endpointstring, int defaultport) { if (string.IsNullOrEmpty(endpointstring) @@ -585,7 +585,7 @@ namespace Emby.Server.Implementations.Networking /// /// The p. /// System.Int32. - /// + /// private static int GetPort(string p) { int port; @@ -605,7 +605,7 @@ namespace Emby.Server.Implementations.Networking /// /// The p. /// IPAddress. - /// + /// private static async Task GetIPfromHost(string p) { var hosts = await Dns.GetHostAddressesAsync(p).ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 6dbefa910..c39897b53 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -469,12 +469,12 @@ namespace Emby.Server.Implementations.Playlists folderPath = folderPath + Path.DirectorySeparatorChar; } - Uri folderUri = new Uri(folderPath); - Uri fileAbsoluteUri = new Uri(fileAbsolutePath); + var folderUri = new Uri(folderPath); + var fileAbsoluteUri = new Uri(fileAbsolutePath); if (folderUri.Scheme != fileAbsoluteUri.Scheme) { return fileAbsolutePath; } // path can't be made relative. - Uri relativeUri = folderUri.MakeRelativeUri(fileAbsoluteUri); + var relativeUri = folderUri.MakeRelativeUri(fileAbsoluteUri); string relativePath = Uri.UnescapeDataString(relativeUri.ToString()); if (fileAbsoluteUri.Scheme.Equals("file", StringComparison.CurrentCultureIgnoreCase)) diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index dc60b9990..44f6e2d7b 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// The task manager. /// The json serializer. /// The logger. - /// + /// /// scheduledTask /// or /// applicationPaths @@ -256,7 +256,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// Gets the triggers that define when the task will run /// /// The triggers. - /// value + /// value public TaskTriggerInfo[] Triggers { get @@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// Task options. /// Task. - /// Cannot execute a Task that is already running + /// Cannot execute a Task that is already running public async Task Execute(TaskOptions options) { var task = Task.Run(async () => await ExecuteInternal(options).ConfigureAwait(false)); @@ -461,7 +461,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// Stops the task if it is currently executing /// - /// Cannot cancel a Task unless it is in the Running state. + /// Cannot cancel a Task unless it is in the Running state. public void Cancel() { if (State != TaskState.Running) @@ -705,8 +705,8 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// The info. /// BaseTaskTrigger. - /// - /// Invalid trigger type: + info.Type + /// + /// Invalid trigger type: + info.Type private ITaskTrigger GetTrigger(TaskTriggerInfo info) { var options = new TaskOptions diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs index 754fb1633..ac47c9625 100644 --- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs +++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs @@ -61,7 +61,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// The application paths. /// The json serializer. /// The logger. - /// kernel + /// kernel public TaskManager(IApplicationPaths applicationPaths, IJsonSerializer jsonSerializer, ILogger logger, IFileSystem fileSystem, ISystemEvents systemEvents) { ApplicationPaths = applicationPaths; diff --git a/Emby.Server.Implementations/Security/EncryptionManager.cs b/Emby.Server.Implementations/Security/EncryptionManager.cs index c60872346..fa8872ccc 100644 --- a/Emby.Server.Implementations/Security/EncryptionManager.cs +++ b/Emby.Server.Implementations/Security/EncryptionManager.cs @@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.Security /// /// The value. /// System.String. - /// value + /// value public string EncryptString(string value) { if (value == null) @@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Security /// /// The value. /// System.String. - /// value + /// value public string DecryptString(string value) { if (value == null) diff --git a/Emby.Server.Implementations/Serialization/JsonSerializer.cs b/Emby.Server.Implementations/Serialization/JsonSerializer.cs index 26c648d72..60bf2d5a9 100644 --- a/Emby.Server.Implementations/Serialization/JsonSerializer.cs +++ b/Emby.Server.Implementations/Serialization/JsonSerializer.cs @@ -27,7 +27,7 @@ namespace Emby.Common.Implementations.Serialization /// /// The obj. /// The stream. - /// obj + /// obj public void SerializeToStream(object obj, Stream stream) { if (obj == null) @@ -48,7 +48,7 @@ namespace Emby.Common.Implementations.Serialization /// /// The obj. /// The file. - /// obj + /// obj public void SerializeToFile(object obj, string file) { if (obj == null) @@ -61,7 +61,7 @@ namespace Emby.Common.Implementations.Serialization throw new ArgumentNullException(nameof(file)); } - using (Stream stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) + using (var stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) { SerializeToStream(obj, stream); } @@ -79,7 +79,7 @@ namespace Emby.Common.Implementations.Serialization /// The type. /// The file. /// System.Object. - /// type + /// type public object DeserializeFromFile(Type type, string file) { if (type == null) @@ -92,7 +92,7 @@ namespace Emby.Common.Implementations.Serialization throw new ArgumentNullException(nameof(file)); } - using (Stream stream = OpenFile(file)) + using (var stream = OpenFile(file)) { return DeserializeFromStream(stream, type); } @@ -104,7 +104,7 @@ namespace Emby.Common.Implementations.Serialization /// /// The file. /// ``0. - /// file + /// file public T DeserializeFromFile(string file) where T : class { @@ -113,7 +113,7 @@ namespace Emby.Common.Implementations.Serialization throw new ArgumentNullException(nameof(file)); } - using (Stream stream = OpenFile(file)) + using (var stream = OpenFile(file)) { return DeserializeFromStream(stream); } @@ -125,7 +125,7 @@ namespace Emby.Common.Implementations.Serialization /// /// The stream. /// ``0. - /// stream + /// stream public T DeserializeFromStream(Stream stream) { if (stream == null) @@ -153,7 +153,7 @@ namespace Emby.Common.Implementations.Serialization /// /// The text. /// ``0. - /// text + /// text public T DeserializeFromString(string text) { if (string.IsNullOrEmpty(text)) @@ -170,7 +170,7 @@ namespace Emby.Common.Implementations.Serialization /// The stream. /// The type. /// System.Object. - /// stream + /// stream public object DeserializeFromStream(Stream stream, Type type) { if (stream == null) @@ -236,7 +236,7 @@ namespace Emby.Common.Implementations.Serialization /// The json. /// The type. /// System.Object. - /// json + /// json public object DeserializeFromString(string json, Type type) { if (string.IsNullOrEmpty(json)) @@ -257,7 +257,7 @@ namespace Emby.Common.Implementations.Serialization /// /// The obj. /// System.String. - /// obj + /// obj public string SerializeToString(object obj) { if (obj == null) diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index f82c64823..b34832f45 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.Services public void RegisterRestPaths(HttpListenerHost appHost, Type requestType, Type serviceType) { var attrs = appHost.GetRouteAttributes(requestType); - foreach (RouteAttribute attr in attrs) + foreach (var attr in attrs) { var restPath = new RestPath(appHost.CreateInstance, appHost.GetParseFn, requestType, serviceType, attr.Path, attr.Verbs, attr.IsHidden, attr.Summary, attr.Description); diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index d99130228..e398b58cc 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -201,8 +201,8 @@ namespace Emby.Server.Implementations.Session /// The remote end point. /// The user. /// Task. - /// user - /// + /// user + /// public SessionInfo LogSessionActivity(string appName, string appVersion, string deviceId, @@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.Session /// Removes the now playing item id. /// /// The session. - /// item + /// item private void RemoveNowPlayingItem(SessionInfo session) { session.NowPlayingItem = null; @@ -404,7 +404,7 @@ namespace Emby.Server.Implementations.Session CheckDisposed(); - SessionInfo sessionInfo = _activeConnections.GetOrAdd(key, k => + var sessionInfo = _activeConnections.GetOrAdd(key, k => { return CreateSession(k, appName, appVersion, deviceId, deviceName, remoteEndPoint, user); }); @@ -571,7 +571,7 @@ namespace Emby.Server.Implementations.Session /// /// The info. /// Task. - /// info + /// info public async Task OnPlaybackStart(PlaybackStartInfo info) { CheckDisposed(); @@ -784,8 +784,8 @@ namespace Emby.Server.Implementations.Session /// /// The info. /// Task. - /// info - /// positionTicks + /// info + /// positionTicks public async Task OnPlaybackStopped(PlaybackStopInfo info) { CheckDisposed(); @@ -1284,8 +1284,8 @@ namespace Emby.Server.Implementations.Session /// /// The session identifier. /// The user identifier. - /// Cannot modify additional users without authenticating first. - /// The requested user is already the primary user of the session. + /// Cannot modify additional users without authenticating first. + /// The requested user is already the primary user of the session. public void AddAdditionalUser(string sessionId, Guid userId) { CheckDisposed(); @@ -1318,8 +1318,8 @@ namespace Emby.Server.Implementations.Session /// /// The session identifier. /// The user identifier. - /// Cannot modify additional users without authenticating first. - /// The requested user is already the primary user of the session. + /// Cannot modify additional users without authenticating first. + /// The requested user is already the primary user of the session. public void RemoveAdditionalUser(string sessionId, Guid userId) { CheckDisposed(); diff --git a/Emby.Server.Implementations/Sorting/AlphanumComparator.cs b/Emby.Server.Implementations/Sorting/AlphanumComparator.cs index f21f905df..2e00c24d7 100644 --- a/Emby.Server.Implementations/Sorting/AlphanumComparator.cs +++ b/Emby.Server.Implementations/Sorting/AlphanumComparator.cs @@ -29,8 +29,8 @@ namespace Emby.Server.Implementations.Sorting char thisCh = s1[thisMarker]; char thatCh = s2[thatMarker]; - StringBuilder thisChunk = new StringBuilder(); - StringBuilder thatChunk = new StringBuilder(); + var thisChunk = new StringBuilder(); + var thatChunk = new StringBuilder(); while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || SortHelper.InChunk(thisCh, thisChunk[0]))) { diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 3a9d99aa1..630ef4893 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.TV OrderBy = new[] { new ValueTuple(ItemSortBy.DatePlayed, SortOrder.Descending) }, SeriesPresentationUniqueKey = presentationUniqueKey, Limit = limit, - DtoOptions = new MediaBrowser.Controller.Dto.DtoOptions + DtoOptions = new DtoOptions { Fields = new ItemFields[] { @@ -196,7 +196,7 @@ namespace Emby.Server.Implementations.TV IsPlayed = true, Limit = 1, ParentIndexNumberNotEquals = 0, - DtoOptions = new MediaBrowser.Controller.Dto.DtoOptions + DtoOptions = new DtoOptions { Fields = new ItemFields[] { diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Detector.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Detector.cs index 507dd5e42..097c7b8b7 100644 --- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Detector.cs +++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Detector.cs @@ -164,7 +164,7 @@ namespace NLangDetect.Core public string Detect() { - List probabilities = GetProbabilities(); + var probabilities = GetProbabilities(); return probabilities.Count > 0 @@ -179,7 +179,7 @@ namespace NLangDetect.Core DetectBlock(); } - List list = SortProbability(_langprob); + var list = SortProbability(_langprob); return list; } @@ -241,7 +241,7 @@ namespace NLangDetect.Core { CleanText(); - List ngrams = ExtractNGrams(); + var ngrams = ExtractNGrams(); if (ngrams.Count == 0) { @@ -250,7 +250,7 @@ namespace NLangDetect.Core _langprob = new double[_langlist.Count]; - Random rand = (_seed.HasValue ? new Random(_seed.Value) : new Random()); + var rand = (_seed.HasValue ? new Random(_seed.Value) : new Random()); for (int t = 0; t < _trialsCount; t++) { @@ -305,7 +305,7 @@ namespace NLangDetect.Core private List ExtractNGrams() { var list = new List(); - NGram ngram = new NGram(); + var ngram = new NGram(); for (int i = 0; i < _text.Length; i++) { @@ -332,7 +332,7 @@ namespace NLangDetect.Core return; } - ProbVector langProbMap = _wordLangProbMap[word]; + var langProbMap = _wordLangProbMap[word]; double weight = alpha / _BaseFreq; for (int i = 0; i < prob.Length; i++) diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/DetectorFactory.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/DetectorFactory.cs index c80757e68..08e98d62e 100644 --- a/Emby.Server.Implementations/TextEncoding/NLangDetect/DetectorFactory.cs +++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/DetectorFactory.cs @@ -54,7 +54,7 @@ namespace NLangDetect.Core public static Detector Create(double alpha) { - Detector detector = CreateDetector(); + var detector = CreateDetector(); detector.SetAlpha(alpha); diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/GenProfile.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/GenProfile.cs index c2b007c05..26157483b 100644 --- a/Emby.Server.Implementations/TextEncoding/NLangDetect/GenProfile.cs +++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/GenProfile.cs @@ -13,8 +13,8 @@ namespace NLangDetect.Core public static LangProfile load(string lang, string file) { - LangProfile profile = new LangProfile(lang); - TagExtractor tagextractor = new TagExtractor("abstract", 100); + var profile = new LangProfile(lang); + var tagextractor = new TagExtractor("abstract", 100); Stream inputStream = null; try @@ -28,7 +28,7 @@ namespace NLangDetect.Core inputStream = new GZipStream(inputStream, CompressionMode.Decompress); } - using (XmlReader xmlReader = XmlReader.Create(inputStream)) + using (var xmlReader = XmlReader.Create(inputStream)) { while (xmlReader.Read()) { diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs index 98c4f623c..a26f236a8 100644 --- a/Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs +++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/LanguageDetector.cs @@ -25,7 +25,7 @@ namespace NLangDetect.Core { if (string.IsNullOrEmpty(plainText)) { throw new ArgumentException("Argument can't be null nor empty.", nameof(plainText)); } - Detector detector = DetectorFactory.Create(_DefaultAlpha); + var detector = DetectorFactory.Create(_DefaultAlpha); detector.Append(plainText); diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/LangProfile.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/LangProfile.cs index 0413edfad..78b44e1fc 100644 --- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/LangProfile.cs +++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/LangProfile.cs @@ -59,8 +59,8 @@ namespace NLangDetect.Core.Utils ICollection keys = freq.Keys; int roman = 0; // TODO IMM HI: move up? - Regex regex1 = new Regex("^[A-Za-z]$", RegexOptions.Compiled); - List keysToRemove = new List(); + var regex1 = new Regex("^[A-Za-z]$", RegexOptions.Compiled); + var keysToRemove = new List(); foreach (string key in keys) { @@ -93,7 +93,7 @@ namespace NLangDetect.Core.Utils ICollection keys2 = freq.Keys; // TODO IMM HI: move up? - Regex regex2 = new Regex(".*[A-Za-z].*", RegexOptions.Compiled); + var regex2 = new Regex(".*[A-Za-z].*", RegexOptions.Compiled); foreach (string key in keys2) { diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs index 058f350b2..d7dab8528 100644 --- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs +++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs @@ -30,7 +30,7 @@ namespace NLangDetect.Core.Utils { var manifestName = typeof(Messages).Assembly.GetManifestResourceNames().FirstOrDefault(i => i.IndexOf("messages.properties", StringComparison.Ordinal) != -1); - Stream messagesStream = + var messagesStream = typeof(Messages).Assembly .GetManifestResourceStream(manifestName); diff --git a/Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs b/Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs index 49a371efa..03ff0863f 100644 --- a/Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs +++ b/Emby.Server.Implementations/TextEncoding/TextEncodingDetect.cs @@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.TextEncoding public CharacterEncoding DetectEncoding(byte[] buffer, int size) { // First check if we have a BOM and return that if so - CharacterEncoding encoding = CheckBom(buffer, size); + var encoding = CheckBom(buffer, size); if (encoding != CharacterEncoding.None) { return encoding; diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CharDistributionAnalyser.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CharDistributionAnalyser.cs index 472dfdc51..601b4906a 100644 --- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CharDistributionAnalyser.cs +++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CharDistributionAnalyser.cs @@ -83,7 +83,7 @@ namespace UniversalDetector.Core /// convert this encoding string to a number, here called order. /// This allow multiple encoding of a language to share one frequency table /// - /// A + /// A /// /// public abstract int GetOrder(byte[] buf, int offset); @@ -91,7 +91,7 @@ namespace UniversalDetector.Core /// /// Feed a character with known length /// - /// A + /// A /// buf offset public void HandleOneChar(byte[] buf, int offset, int charLen) { diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CharsetProber.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CharsetProber.cs index 158dc8969..e61e5848d 100644 --- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CharsetProber.cs +++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/CharsetProber.cs @@ -108,7 +108,7 @@ namespace UniversalDetector.Core { byte[] result = null; - using (MemoryStream ms = new MemoryStream(buf.Length)) + using (var ms = new MemoryStream(buf.Length)) { bool meetMSB = false; @@ -156,7 +156,7 @@ namespace UniversalDetector.Core { byte[] result = null; - using (MemoryStream ms = new MemoryStream(buf.Length)) + using (var ms = new MemoryStream(buf.Length)) { bool inTag = false; diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/EscCharsetProber.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/EscCharsetProber.cs index e8da73c1c..b10c41c77 100644 --- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/EscCharsetProber.cs +++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/EscCharsetProber.cs @@ -84,7 +84,7 @@ namespace UniversalDetector.Core } else if (j != activeSM) { - CodingStateMachine t = codingSM[activeSM]; + var t = codingSM[activeSM]; codingSM[activeSM] = codingSM[j]; codingSM[j] = t; } diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/MBCSGroupProber.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/MBCSGroupProber.cs index e7fa2d719..b23e499c3 100644 --- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/MBCSGroupProber.cs +++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/MBCSGroupProber.cs @@ -122,7 +122,7 @@ namespace UniversalDetector.Core } } - ProbingState st = ProbingState.NotMe; + var st = ProbingState.NotMe; for (int i = 0; i < probers.Length; i++) { diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SBCSGroupProber.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SBCSGroupProber.cs index 336726aab..cdbc16891 100644 --- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SBCSGroupProber.cs +++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/SBCSGroupProber.cs @@ -59,7 +59,7 @@ namespace UniversalDetector.Core probers[7] = new SingleByteCharSetProber(new Win1253Model()); probers[8] = new SingleByteCharSetProber(new Latin5BulgarianModel()); probers[9] = new SingleByteCharSetProber(new Win1251BulgarianModel()); - HebrewProber hebprober = new HebrewProber(); + var hebprober = new HebrewProber(); probers[10] = hebprober; // Logical probers[11] = new SingleByteCharSetProber(new Win1255Model(), false, hebprober); @@ -75,7 +75,7 @@ namespace UniversalDetector.Core public override ProbingState HandleData(byte[] buf, int offset, int len) { - ProbingState st = ProbingState.NotMe; + var st = ProbingState.NotMe; //apply filter to original buffer, and we got new buffer back //depend on what script it is, we will feed them the new buffer diff --git a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/UniversalDetector.cs b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/UniversalDetector.cs index 28a50ea3e..812a9a793 100644 --- a/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/UniversalDetector.cs +++ b/Emby.Server.Implementations/TextEncoding/UniversalDetector/Core/UniversalDetector.cs @@ -168,7 +168,7 @@ namespace UniversalDetector.Core } } - ProbingState st = ProbingState.NotMe; + var st = ProbingState.NotMe; switch (inputState) { diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 74d66fd41..68cb7821d 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -415,7 +415,7 @@ namespace Emby.Server.Implementations.Updates /// The progress. /// The cancellation token. /// Task. - /// package + /// package public async Task InstallPackage(PackageVersionInfo package, bool isPlugin, IProgress progress, CancellationToken cancellationToken) { if (package == null) @@ -626,7 +626,7 @@ namespace Emby.Server.Implementations.Updates /// Uninstalls a plugin /// /// The plugin. - /// + /// public void UninstallPlugin(IPlugin plugin) { plugin.OnUninstalling(); diff --git a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs index aa4840664..8234393c2 100644 --- a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs +++ b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs @@ -34,7 +34,7 @@ namespace Emby.XmlTv.Classes private static XmlReader CreateXmlTextReader(string path) { - XmlReaderSettings settings = new XmlReaderSettings(); + var settings = new XmlReaderSettings(); // https://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.xmlresolver(v=vs.110).aspx // Looks like we don't need this anyway? diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 15a01ec3c..62c65d32e 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -36,8 +36,8 @@ namespace Jellyfin.Server public static async Task Main(string[] args) { - StartupOptions options = new StartupOptions(args); - Version version = Assembly.GetEntryAssembly().GetName().Version; + var options = new StartupOptions(args); + var version = Assembly.GetEntryAssembly().GetName().Version; if (options.ContainsOption("-v") || options.ContainsOption("--version")) { @@ -45,7 +45,7 @@ namespace Jellyfin.Server return 0; } - ServerApplicationPaths appPaths = createApplicationPaths(options); + var appPaths = createApplicationPaths(options); // $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", appPaths.LogDirectoryPath); await createLogger(appPaths); @@ -57,7 +57,7 @@ namespace Jellyfin.Server _logger.LogInformation("Jellyfin version: {Version}", version); - EnvironmentInfo environmentInfo = new EnvironmentInfo(getOperatingSystem()); + var environmentInfo = new EnvironmentInfo(getOperatingSystem()); ApplicationHost.LogEnvironmentInfo(_logger, appPaths, environmentInfo); SQLitePCL.Batteries_V2.Init(); @@ -173,7 +173,7 @@ namespace Jellyfin.Server if (!File.Exists(configPath)) { // For some reason the csproj name is used instead of the assembly name - using (Stream rscstr = typeof(Program).Assembly + using (var rscstr = typeof(Program).Assembly .GetManifestResourceStream("Jellyfin.Server.Resources.Configuration.logging.json")) using (Stream fstr = File.Open(configPath, FileMode.CreateNew)) { diff --git a/Jellyfin.Server/SocketSharp/RequestMono.cs b/Jellyfin.Server/SocketSharp/RequestMono.cs index 6e5a4e75a..0e3d2ad65 100644 --- a/Jellyfin.Server/SocketSharp/RequestMono.cs +++ b/Jellyfin.Server/SocketSharp/RequestMono.cs @@ -75,7 +75,7 @@ namespace Jellyfin.SocketSharp // // We use a substream, as in 2.x we will support large uploads streamed to disk, // - HttpPostedFile sub = new HttpPostedFile(e.Filename, e.ContentType, input, e.Start, e.Length); + var sub = new HttpPostedFile(e.Filename, e.ContentType, input, e.Start, e.Length); files[e.Name] = sub; } } @@ -207,17 +207,17 @@ namespace Jellyfin.SocketSharp async Task LoadWwwForm(WebROCollection form) { - using (Stream input = InputStream) + using (var input = InputStream) { using (var ms = new MemoryStream()) { await input.CopyToAsync(ms).ConfigureAwait(false); ms.Position = 0; - using (StreamReader s = new StreamReader(ms, ContentEncoding)) + using (var s = new StreamReader(ms, ContentEncoding)) { - StringBuilder key = new StringBuilder(); - StringBuilder value = new StringBuilder(); + var key = new StringBuilder(); + var value = new StringBuilder(); int c; while ((c = s.Read()) != -1) @@ -269,7 +269,7 @@ namespace Jellyfin.SocketSharp { public override string ToString() { - StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); foreach (var pair in this) { if (result.Length > 0) @@ -715,7 +715,7 @@ namespace Jellyfin.SocketSharp if (at_eof || ReadBoundary()) return null; - Element elem = new Element(); + var elem = new Element(); string header; while ((header = ReadHeaders()) != null) { diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 12d807a7e..1248f7316 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -902,7 +902,7 @@ namespace MediaBrowser.Api.Library var dtoOptions = GetDtoOptions(_authContext, request); - BaseItem parent = item.GetParent(); + var parent = item.GetParent(); while (parent != null) { diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index cdf9c7d0b..6d4af16e7 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -751,7 +751,7 @@ namespace MediaBrowser.Api.Playback MediaSourceInfo mediaSource = null; if (string.IsNullOrWhiteSpace(request.LiveStreamId)) { - TranscodingJob currentJob = !string.IsNullOrWhiteSpace(request.PlaySessionId) ? + var currentJob = !string.IsNullOrWhiteSpace(request.PlaySessionId) ? ApiEntryPoint.Instance.GetTranscodingJob(request.PlaySessionId) : null; diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs index 502403cfe..16b036912 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs @@ -168,7 +168,7 @@ namespace MediaBrowser.Api.ScheduledTasks /// /// The request. /// IEnumerable{TaskInfo}. - /// Task not found + /// Task not found public object Get(GetScheduledTask request) { var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); @@ -187,7 +187,7 @@ namespace MediaBrowser.Api.ScheduledTasks /// Posts the specified request. /// /// The request. - /// Task not found + /// Task not found public void Post(StartScheduledTask request) { var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); @@ -214,7 +214,7 @@ namespace MediaBrowser.Api.ScheduledTasks /// Posts the specified request. /// /// The request. - /// Task not found + /// Task not found public void Delete(StopScheduledTask request) { var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); @@ -231,7 +231,7 @@ namespace MediaBrowser.Api.ScheduledTasks /// Posts the specified request. /// /// The request. - /// Task not found + /// Task not found public void Post(UpdateScheduledTaskTriggers request) { // We need to parse this manually because we told service stack not to with IRequiresRequestStream diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index 20a6969df..44bb24ef2 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -95,7 +95,7 @@ namespace MediaBrowser.Api var items = GetSimilaritems(item, libraryManager, inputItems, getSimilarityScore) .ToList(); - List returnItems = items; + var returnItems = items; if (request.Limit.HasValue) { diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index 3daa5779c..4cccc0cb5 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -459,7 +459,7 @@ namespace MediaBrowser.Api.UserLibrary if (string.IsNullOrEmpty(val)) { - return Array.Empty>(); + return Array.Empty>(); } var vals = val.Split(','); @@ -470,7 +470,7 @@ namespace MediaBrowser.Api.UserLibrary var sortOrders = requestedSortOrder.Split(','); - var result = new ValueTuple[vals.Length]; + var result = new ValueTuple[vals.Length]; for (var i = 0; i < vals.Length; i++) { @@ -479,7 +479,7 @@ namespace MediaBrowser.Api.UserLibrary var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null; var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase) ? MediaBrowser.Model.Entities.SortOrder.Descending : MediaBrowser.Model.Entities.SortOrder.Ascending; - result[i] = new ValueTuple(vals[i], sortOrder); + result[i] = new ValueTuple(vals[i], sortOrder); } return result; diff --git a/MediaBrowser.Common/Net/IHttpClient.cs b/MediaBrowser.Common/Net/IHttpClient.cs index 5f4e3e5d1..5aaf7e0be 100644 --- a/MediaBrowser.Common/Net/IHttpClient.cs +++ b/MediaBrowser.Common/Net/IHttpClient.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Common.Net /// The options. /// Task{System.String}. /// progress - /// + /// Task GetTempFile(HttpRequestOptions options); /// diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs index a14c9fb34..1ff2e98ef 100644 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ b/MediaBrowser.Common/Plugins/BasePlugin.cs @@ -212,7 +212,7 @@ namespace MediaBrowser.Common.Plugins /// Returns true or false indicating success or failure /// /// The configuration. - /// configuration + /// configuration public virtual void UpdateConfiguration(BasePluginConfiguration configuration) { if (configuration == null) diff --git a/MediaBrowser.Common/Plugins/IPlugin.cs b/MediaBrowser.Common/Plugins/IPlugin.cs index 037e11ce8..32527c299 100644 --- a/MediaBrowser.Common/Plugins/IPlugin.cs +++ b/MediaBrowser.Common/Plugins/IPlugin.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Common.Plugins /// Returns true or false indicating success or failure /// /// The configuration. - /// configuration + /// configuration void UpdateConfiguration(BasePluginConfiguration configuration); /// diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs index 52d5d7dcb..8bef78400 100644 --- a/MediaBrowser.Common/Updates/IInstallationManager.cs +++ b/MediaBrowser.Common/Updates/IInstallationManager.cs @@ -108,14 +108,14 @@ namespace MediaBrowser.Common.Updates /// The progress. /// The cancellation token. /// Task. - /// package + /// package Task InstallPackage(PackageVersionInfo package, bool isPlugin, IProgress progress, CancellationToken cancellationToken); /// /// Uninstalls a plugin /// /// The plugin. - /// + /// void UninstallPlugin(IPlugin plugin); } } diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 522b3e33e..054df21e5 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -164,7 +164,7 @@ namespace MediaBrowser.Controller.Entities /// Adds the virtual child. /// /// The child. - /// + /// public void AddVirtualChild(BaseItem child) { if (child == null) @@ -180,7 +180,7 @@ namespace MediaBrowser.Controller.Entities /// /// The id. /// BaseItem. - /// id + /// id public BaseItem FindVirtualChild(Guid id) { if (id.Equals(Guid.Empty)) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 995f39483..68374c8df 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -367,7 +367,7 @@ namespace MediaBrowser.Controller.Entities } char thisCh = s1[thisMarker]; - StringBuilder thisChunk = new StringBuilder(); + var thisChunk = new StringBuilder(); while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || SortHelper.InChunk(thisCh, thisChunk[0]))) { @@ -548,9 +548,9 @@ namespace MediaBrowser.Controller.Entities public static IMediaSourceManager MediaSourceManager { get; set; } /// - /// Returns a that represents this instance. + /// Returns a that represents this instance. /// - /// A that represents this instance. + /// A that represents this instance. public override string ToString() { return Name; @@ -1661,7 +1661,7 @@ namespace MediaBrowser.Controller.Entities /// /// The user. /// true if [is parental allowed] [the specified user]; otherwise, false. - /// user + /// user public bool IsParentalAllowed(User user) { if (user == null) @@ -1811,7 +1811,7 @@ namespace MediaBrowser.Controller.Entities /// /// The user. /// true if the specified user is visible; otherwise, false. - /// user + /// user public virtual bool IsVisible(User user) { if (user == null) @@ -1971,7 +1971,7 @@ namespace MediaBrowser.Controller.Entities /// Adds a studio to the item /// /// The name. - /// + /// public void AddStudio(string name) { if (string.IsNullOrEmpty(name)) @@ -2004,7 +2004,7 @@ namespace MediaBrowser.Controller.Entities /// Adds a genre to the item /// /// The name. - /// + /// public void AddGenre(string name) { if (string.IsNullOrEmpty(name)) @@ -2028,7 +2028,7 @@ namespace MediaBrowser.Controller.Entities /// The date played. /// if set to true [reset position]. /// Task. - /// + /// public virtual void MarkPlayed(User user, DateTime? datePlayed, bool resetPosition) @@ -2065,7 +2065,7 @@ namespace MediaBrowser.Controller.Entities /// /// The user. /// Task. - /// + /// public virtual void MarkUnplayed(User user) { if (user == null) @@ -2104,7 +2104,7 @@ namespace MediaBrowser.Controller.Entities /// The type. /// Index of the image. /// true if the specified type has image; otherwise, false. - /// Backdrops should be accessed using Item.Backdrops + /// Backdrops should be accessed using Item.Backdrops public bool HasImage(ImageType type, int imageIndex) { return GetImageInfo(type, imageIndex) != null; @@ -2232,9 +2232,9 @@ namespace MediaBrowser.Controller.Entities /// Type of the image. /// Index of the image. /// System.String. - /// + /// /// - /// item + /// item public string GetImagePath(ImageType imageType, int imageIndex) { var info = GetImageInfo(imageType, imageIndex); @@ -2294,7 +2294,7 @@ namespace MediaBrowser.Controller.Entities /// Type of the image. /// The images. /// true if XXXX, false otherwise. - /// Cannot call AddImages with chapter images + /// Cannot call AddImages with chapter images public bool AddImages(ImageType imageType, List images) { if (imageType == ImageType.Chapter) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index fe53d2f05..bbee594f6 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -135,7 +135,7 @@ namespace MediaBrowser.Controller.Entities /// The item. /// The cancellation token. /// Task. - /// Unable to add + item.Name + /// Unable to add + item.Name public void AddChild(BaseItem item, CancellationToken cancellationToken) { item.SetParent(this); @@ -1261,7 +1261,7 @@ namespace MediaBrowser.Controller.Entities /// The user. /// if set to true [include linked children]. /// IEnumerable{BaseItem}. - /// + /// public IEnumerable GetRecursiveChildren(User user, bool includeLinkedChildren = true) { return GetRecursiveChildren(user, null); diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 0ba8b3b48..dd0183489 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -175,9 +175,9 @@ namespace MediaBrowser.Controller.Entities public Dictionary ProviderIds { get; set; } /// - /// Returns a that represents this instance. + /// Returns a that represents this instance. /// - /// A that represents this instance. + /// A that represents this instance. public override string ToString() { return Name; diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 5ba4613c0..4539ab0f2 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -119,7 +119,7 @@ namespace MediaBrowser.Controller.Entities.TV IncludeItemTypes = new[] { typeof(Season).Name }, IsVirtualItem = false, Limit = 0, - DtoOptions = new Dto.DtoOptions(false) + DtoOptions = new DtoOptions(false) { EnableImages = false } @@ -136,7 +136,7 @@ namespace MediaBrowser.Controller.Entities.TV { AncestorWithPresentationUniqueKey = null, SeriesPresentationUniqueKey = seriesKey, - DtoOptions = new Dto.DtoOptions(false) + DtoOptions = new DtoOptions(false) { EnableImages = false } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 16fef9a82..10fe096a4 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -149,7 +149,7 @@ namespace MediaBrowser.Controller.Entities /// /// The new name. /// Task. - /// + /// public Task Rename(string newName) { if (string.IsNullOrEmpty(newName)) diff --git a/MediaBrowser.Controller/Entities/UserItemData.cs b/MediaBrowser.Controller/Entities/UserItemData.cs index 8a87aff5f..f7136bdf2 100644 --- a/MediaBrowser.Controller/Entities/UserItemData.cs +++ b/MediaBrowser.Controller/Entities/UserItemData.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the users 0-10 rating /// /// The rating. - /// Rating;A 0 to 10 rating is required for UserItemData. + /// Rating;A 0 to 10 rating is required for UserItemData. public double? Rating { get => _rating; diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index e7c27d846..4bbb60283 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -34,7 +34,7 @@ namespace MediaBrowser.Controller.IO /// The flatten folder depth. /// if set to true [resolve shortcuts]. /// Dictionary{System.StringFileSystemInfo}. - /// path + /// path public static FileSystemMetadata[] GetFilteredFileSystemEntries(IDirectoryService directoryService, string path, IFileSystem fileSystem, diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 0ada91b2e..9d404ba1a 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -100,7 +100,7 @@ namespace MediaBrowser.Controller.Library /// /// The value. /// Task{Year}. - /// + /// Year GetYear(int value); /// diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index bf60aa25a..925d91a37 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Controller.Library /// /// The id. /// User. - /// + /// User GetUserById(Guid id); /// @@ -73,16 +73,16 @@ namespace MediaBrowser.Controller.Library /// The user. /// The new name. /// Task. - /// user - /// + /// user + /// Task RenameUser(User user, string newName); /// /// Updates the user. /// /// The user. - /// user - /// + /// user + /// void UpdateUser(User user); /// @@ -90,8 +90,8 @@ namespace MediaBrowser.Controller.Library /// /// The name. /// User. - /// name - /// + /// name + /// Task CreateUser(string name); /// @@ -99,8 +99,8 @@ namespace MediaBrowser.Controller.Library /// /// The user. /// Task. - /// user - /// + /// user + /// Task DeleteUser(User user); /// diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index eb459e890..7bb8325f8 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Library /// Adds the additional location. /// /// The path. - /// + /// public void AddAdditionalLocation(string path) { if (string.IsNullOrEmpty(path)) @@ -173,7 +173,7 @@ namespace MediaBrowser.Controller.Library /// /// The name. /// FileSystemInfo. - /// + /// public FileSystemMetadata GetFileSystemEntryByName(string name) { if (string.IsNullOrEmpty(name)) @@ -189,7 +189,7 @@ namespace MediaBrowser.Controller.Library /// /// The path. /// FileSystemInfo. - /// + /// public FileSystemMetadata GetFileSystemEntryByPath(string path) { if (string.IsNullOrEmpty(path)) @@ -228,10 +228,10 @@ namespace MediaBrowser.Controller.Library #region Equality Overrides /// - /// Determines whether the specified is equal to this instance. + /// Determines whether the specified is equal to this instance. /// /// The object to compare with the current object. - /// true if the specified is equal to this instance; otherwise, false. + /// true if the specified is equal to this instance; otherwise, false. public override bool Equals(object obj) { return Equals(obj as ItemResolveArgs); diff --git a/MediaBrowser.Controller/Net/IWebSocketConnection.cs b/MediaBrowser.Controller/Net/IWebSocketConnection.cs index 6d31c6dbb..a09b2f7a2 100644 --- a/MediaBrowser.Controller/Net/IWebSocketConnection.cs +++ b/MediaBrowser.Controller/Net/IWebSocketConnection.cs @@ -62,7 +62,7 @@ namespace MediaBrowser.Controller.Net /// The message. /// The cancellation token. /// Task. - /// message + /// message Task SendAsync(WebSocketMessage message, CancellationToken cancellationToken); /// @@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Net /// The text. /// The cancellation token. /// Task. - /// buffer + /// buffer Task SendAsync(string text, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 6a4f0aa08..771027103 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.Session /// /// The info. /// Task. - /// + /// Task OnPlaybackProgress(PlaybackProgressInfo info); Task OnPlaybackProgress(PlaybackProgressInfo info, bool isAutomated); @@ -100,7 +100,7 @@ namespace MediaBrowser.Controller.Session /// /// The info. /// Task. - /// + /// Task OnPlaybackStopped(PlaybackStopInfo info); /// diff --git a/MediaBrowser.Controller/Sorting/SortExtensions.cs b/MediaBrowser.Controller/Sorting/SortExtensions.cs index 56d9c1a64..111f4f17f 100644 --- a/MediaBrowser.Controller/Sorting/SortExtensions.cs +++ b/MediaBrowser.Controller/Sorting/SortExtensions.cs @@ -72,8 +72,8 @@ namespace MediaBrowser.Controller.Sorting char thisCh = s1[thisMarker]; char thatCh = s2[thatMarker]; - StringBuilder thisChunk = new StringBuilder(); - StringBuilder thatChunk = new StringBuilder(); + var thisChunk = new StringBuilder(); + var thatChunk = new StringBuilder(); while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || InChunk(thisCh, thisChunk[0]))) { diff --git a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs index 0a4928ed7..e4efa2c35 100644 --- a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs @@ -96,7 +96,7 @@ namespace MediaBrowser.LocalMetadata.Images public List GetImages(BaseItem item, IEnumerable paths, bool arePathsInMediaFolders, IDirectoryService directoryService) { - IEnumerable files = paths.SelectMany(i => _fileSystem.GetFiles(i, BaseItem.SupportedImageExtensions, true, false)); + var files = paths.SelectMany(i => _fileSystem.GetFiles(i, BaseItem.SupportedImageExtensions, true, false)); files = files .OrderBy(i => Array.IndexOf(BaseItem.SupportedImageExtensions, i.Extension ?? string.Empty)); diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index fef673bfd..0ee283325 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -51,7 +51,7 @@ namespace MediaBrowser.LocalMetadata.Parsers /// The item. /// The metadata file. /// The cancellation token. - /// + /// public void Fetch(MetadataResult item, string metadataFile, CancellationToken cancellationToken) { if (item == null) @@ -102,7 +102,7 @@ namespace MediaBrowser.LocalMetadata.Parsers { item.ResetPeople(); - using (Stream fileStream = FileSystem.OpenRead(metadataFile)) + using (var fileStream = FileSystem.OpenRead(metadataFile)) { using (var streamReader = new StreamReader(fileStream, encoding)) { @@ -263,7 +263,7 @@ namespace MediaBrowser.LocalMetadata.Parsers { MetadataFields field; - if (Enum.TryParse(i, true, out field)) + if (Enum.TryParse(i, true, out field)) { return (MetadataFields?)field; } @@ -384,7 +384,7 @@ namespace MediaBrowser.LocalMetadata.Parsers case "Director": { - foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new Controller.Entities.PersonInfo { Name = v.Trim(), Type = PersonType.Director })) + foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Director })) { if (string.IsNullOrWhiteSpace(p.Name)) { @@ -396,7 +396,7 @@ namespace MediaBrowser.LocalMetadata.Parsers } case "Writer": { - foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new Controller.Entities.PersonInfo { Name = v.Trim(), Type = PersonType.Writer })) + foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Writer })) { if (string.IsNullOrWhiteSpace(p.Name)) { @@ -421,7 +421,7 @@ namespace MediaBrowser.LocalMetadata.Parsers else { // Old-style piped string - foreach (var p in SplitNames(actors).Select(v => new Controller.Entities.PersonInfo { Name = v.Trim(), Type = PersonType.Actor })) + foreach (var p in SplitNames(actors).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor })) { if (string.IsNullOrWhiteSpace(p.Name)) { @@ -435,7 +435,7 @@ namespace MediaBrowser.LocalMetadata.Parsers case "GuestStars": { - foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new Controller.Entities.PersonInfo { Name = v.Trim(), Type = PersonType.GuestStar })) + foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.GuestStar })) { if (string.IsNullOrWhiteSpace(p.Name)) { diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs index 2ddf922f9..2eac35f28 100644 --- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs @@ -130,7 +130,7 @@ namespace MediaBrowser.LocalMetadata.Savers CloseOutput = false }; - using (XmlWriter writer = XmlWriter.Create(stream, settings)) + using (var writer = XmlWriter.Create(stream, settings)) { var root = GetRootElementName(item); diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 262772959..c0578aad1 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -152,7 +152,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private string GetProcessOutput(string path, string arguments) { - IProcess process = _processFactory.Create(new ProcessOptions + var process = _processFactory.Create(new ProcessOptions { CreateNoWindow = true, UseShellExecute = false, diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 8489cc9b1..63642b571 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -457,7 +457,7 @@ namespace MediaBrowser.MediaEncoding.Encoder /// The input files. /// The protocol. /// System.String. - /// Unrecognized InputType + /// Unrecognized InputType public string GetInputArgument(string[] inputFiles, MediaProtocol protocol) { return EncodingUtils.GetInputArgument(inputFiles.ToList(), protocol); diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 51d2bcba7..7b8964707 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -300,7 +300,7 @@ namespace MediaBrowser.MediaEncoding.Probing private void ReadFromDictNode(XmlReader reader, MediaInfo info) { string currentKey = null; - List pairs = new List(); + var pairs = new List(); reader.MoveToContent(); reader.Read(); @@ -360,7 +360,7 @@ namespace MediaBrowser.MediaEncoding.Probing private List ReadValueArray(XmlReader reader) { - List pairs = new List(); + var pairs = new List(); reader.MoveToContent(); reader.Read(); @@ -881,7 +881,7 @@ namespace MediaBrowser.MediaEncoding.Probing } } - private void SetSize(InternalMediaInfoResult data, Model.MediaInfo.MediaInfo info) + private void SetSize(InternalMediaInfoResult data, MediaInfo info) { if (data.format != null) { @@ -901,7 +901,7 @@ namespace MediaBrowser.MediaEncoding.Probing var composer = FFProbeHelpers.GetDictionaryValue(tags, "composer"); if (!string.IsNullOrWhiteSpace(composer)) { - List peoples = new List(); + var peoples = new List(); foreach (var person in Split(composer, false)) { peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Composer }); @@ -932,7 +932,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrWhiteSpace(writer)) { - List peoples = new List(); + var peoples = new List(); foreach (var person in Split(writer, false)) { peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Writer }); @@ -1125,7 +1125,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(val)) { var studios = Split(val, true); - List studioList = new List(); + var studioList = new List(); foreach (var studio in studios) { @@ -1160,7 +1160,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(val)) { - List genres = new List(info.Genres); + var genres = new List(info.Genres); foreach (var genre in Split(val, true)) { genres.Add(genre); diff --git a/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs b/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs index 0aa6a3e44..7f312eaec 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles public SubtitleTrackInfo Parse(Stream stream, CancellationToken cancellationToken) { var trackInfo = new SubtitleTrackInfo(); - List trackEvents = new List(); + var trackEvents = new List(); var eventIndex = 1; using (var reader = new StreamReader(stream)) { diff --git a/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs b/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs index c3f6d4947..02ce71ec3 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles public SubtitleTrackInfo Parse(Stream stream, CancellationToken cancellationToken) { var trackInfo = new SubtitleTrackInfo(); - List trackEvents = new List(); + var trackEvents = new List(); using (var reader = new StreamReader(stream)) { string line; diff --git a/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs b/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs index 1cd714f32..8281de764 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles public SubtitleTrackInfo Parse(Stream stream, CancellationToken cancellationToken) { var trackInfo = new SubtitleTrackInfo(); - List trackEvents = new List(); + var trackEvents = new List(); using (var reader = new StreamReader(stream)) { diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 3b7514613..4f424d39b 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -408,7 +408,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// The output path. /// The cancellation token. /// Task. - /// + /// /// inputPath /// or /// outputPath @@ -525,7 +525,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// The output path. /// The cancellation token. /// Task. - /// Must use inputPath list overload + /// Must use inputPath list overload private async Task ExtractTextSubtitle( string[] inputFiles, MediaProtocol protocol, @@ -734,7 +734,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { if (protocol == MediaProtocol.Http) { - HttpRequestOptions opts = new HttpRequestOptions() + var opts = new HttpRequestOptions() { Url = path, CancellationToken = cancellationToken diff --git a/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs b/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs index d67d1dad8..2e328ba63 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs @@ -19,8 +19,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles { cancellationToken.ThrowIfCancellationRequested(); - TimeSpan startTime = TimeSpan.FromTicks(trackEvent.StartPositionTicks); - TimeSpan endTime = TimeSpan.FromTicks(trackEvent.EndPositionTicks); + var startTime = TimeSpan.FromTicks(trackEvent.StartPositionTicks); + var endTime = TimeSpan.FromTicks(trackEvent.EndPositionTicks); // make sure the start and end times are different and seqential if (endTime.TotalMilliseconds <= startTime.TotalMilliseconds) diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs index ec9b276a0..b3d035be2 100644 --- a/MediaBrowser.Model/Configuration/LibraryOptions.cs +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -100,7 +100,7 @@ namespace MediaBrowser.Model.Configuration public ImageOption GetImageOptions(ImageType type) { - foreach (ImageOption i in ImageOptions) + foreach (var i in ImageOptions) { if (i.Type == type) { @@ -111,7 +111,7 @@ namespace MediaBrowser.Model.Configuration ImageOption[] options; if (DefaultImageOptions.TryGetValue(Type, out options)) { - foreach (ImageOption i in options) + foreach (var i in options) { if (i.Type == type) { diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs index fe8926735..ae7d17275 100644 --- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs +++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs @@ -267,7 +267,7 @@ namespace MediaBrowser.Model.Dlna return !condition.IsRequired; } - TransportStreamTimestamp expected = (TransportStreamTimestamp)Enum.Parse(typeof(TransportStreamTimestamp), condition.Value, true); + var expected = (TransportStreamTimestamp)Enum.Parse(typeof(TransportStreamTimestamp), condition.Value, true); switch (condition.Condition) { diff --git a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs index ecca415d3..b71531bf1 100644 --- a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs +++ b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs @@ -24,14 +24,14 @@ namespace MediaBrowser.Model.Dlna // 0 = native, 1 = transcoded var orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1"; - DlnaFlags flagValue = DlnaFlags.BackgroundTransferMode | + var flagValue = DlnaFlags.BackgroundTransferMode | DlnaFlags.InteractiveTransferMode | DlnaFlags.DlnaV15; string dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}", DlnaMaps.FlagsToString(flagValue)); - ResponseProfile mediaProfile = _profile.GetImageMediaProfile(container, + var mediaProfile = _profile.GetImageMediaProfile(container, width, height); @@ -66,7 +66,7 @@ namespace MediaBrowser.Model.Dlna // 0 = native, 1 = transcoded string orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1"; - DlnaFlags flagValue = DlnaFlags.StreamingTransferMode | + var flagValue = DlnaFlags.StreamingTransferMode | DlnaFlags.BackgroundTransferMode | DlnaFlags.InteractiveTransferMode | DlnaFlags.DlnaV15; @@ -83,7 +83,7 @@ namespace MediaBrowser.Model.Dlna string dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}", DlnaMaps.FlagsToString(flagValue)); - ResponseProfile mediaProfile = _profile.GetAudioMediaProfile(container, + var mediaProfile = _profile.GetAudioMediaProfile(container, audioCodec, audioChannels, audioBitrate, @@ -131,7 +131,7 @@ namespace MediaBrowser.Model.Dlna // 0 = native, 1 = transcoded string orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1"; - DlnaFlags flagValue = DlnaFlags.StreamingTransferMode | + var flagValue = DlnaFlags.StreamingTransferMode | DlnaFlags.BackgroundTransferMode | DlnaFlags.InteractiveTransferMode | DlnaFlags.DlnaV15; @@ -148,7 +148,7 @@ namespace MediaBrowser.Model.Dlna string dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}", DlnaMaps.FlagsToString(flagValue)); - ResponseProfile mediaProfile = _profile.GetVideoMediaProfile(container, + var mediaProfile = _profile.GetVideoMediaProfile(container, audioCodec, videoCodec, width, @@ -168,7 +168,7 @@ namespace MediaBrowser.Model.Dlna videoCodecTag, isAvc); - List orgPnValues = new List(); + var orgPnValues = new List(); if (mediaProfile != null && !string.IsNullOrEmpty(mediaProfile.OrgPn)) { @@ -183,7 +183,7 @@ namespace MediaBrowser.Model.Dlna } } - List contentFeatureList = new List(); + var contentFeatureList = new List(); foreach (string orgPn in orgPnValues) { diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs index 3a626deaa..8124cf528 100644 --- a/MediaBrowser.Model/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs @@ -21,7 +21,7 @@ namespace MediaBrowser.Model.Dlna /// Gets or sets the identification. /// /// The identification. - public MediaBrowser.Model.Dlna.DeviceIdentification Identification { get; set; } + public DeviceIdentification Identification { get; set; } public string FriendlyName { get; set; } public string Manufacturer { get; set; } @@ -191,7 +191,7 @@ namespace MediaBrowser.Model.Dlna var conditionProcessor = new ConditionProcessor(); var anyOff = false; - foreach (ProfileCondition c in i.Conditions) + foreach (var c in i.Conditions) { if (!conditionProcessor.IsAudioConditionSatisfied(GetModelProfileCondition(c), audioChannels, audioBitrate, audioSampleRate, audioBitDepth)) { @@ -238,7 +238,7 @@ namespace MediaBrowser.Model.Dlna var conditionProcessor = new ConditionProcessor(); var anyOff = false; - foreach (ProfileCondition c in i.Conditions) + foreach (var c in i.Conditions) { if (!conditionProcessor.IsImageConditionSatisfied(GetModelProfileCondition(c), width, height)) { @@ -304,7 +304,7 @@ namespace MediaBrowser.Model.Dlna var conditionProcessor = new ConditionProcessor(); var anyOff = false; - foreach (ProfileCondition c in i.Conditions) + foreach (var c in i.Conditions) { if (!conditionProcessor.IsVideoConditionSatisfied(GetModelProfileCondition(c), width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isInterlaced, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc)) { diff --git a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs index 42c78e335..672784589 100644 --- a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs +++ b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs @@ -91,7 +91,7 @@ namespace MediaBrowser.Model.Dlna if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg2video")) { - List list = new List(); + var list = new List(); list.Add(ValueOf("MPEG_TS_SD_NA" + suffix)); list.Add(ValueOf("MPEG_TS_SD_EU" + suffix)); diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index f1ec71d1d..2335f0553 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Model.Dlna ValidateAudioInput(options); var mediaSources = new List(); - foreach (MediaSourceInfo i in options.MediaSources) + foreach (var i in options.MediaSources) { if (string.IsNullOrEmpty(options.MediaSourceId) || StringHelper.EqualsIgnoreCase(i.Id, options.MediaSourceId)) @@ -42,16 +42,16 @@ namespace MediaBrowser.Model.Dlna } var streams = new List(); - foreach (MediaSourceInfo i in mediaSources) + foreach (var i in mediaSources) { - StreamInfo streamInfo = BuildAudioItem(i, options); + var streamInfo = BuildAudioItem(i, options); if (streamInfo != null) { streams.Add(streamInfo); } } - foreach (StreamInfo stream in streams) + foreach (var stream in streams) { stream.DeviceId = options.DeviceId; stream.DeviceProfileId = options.Profile.Id; @@ -65,7 +65,7 @@ namespace MediaBrowser.Model.Dlna ValidateInput(options); var mediaSources = new List(); - foreach (MediaSourceInfo i in options.MediaSources) + foreach (var i in options.MediaSources) { if (string.IsNullOrEmpty(options.MediaSourceId) || StringHelper.EqualsIgnoreCase(i.Id, options.MediaSourceId)) @@ -75,16 +75,16 @@ namespace MediaBrowser.Model.Dlna } var streams = new List(); - foreach (MediaSourceInfo i in mediaSources) + foreach (var i in mediaSources) { - StreamInfo streamInfo = BuildVideoItem(i, options); + var streamInfo = BuildVideoItem(i, options); if (streamInfo != null) { streams.Add(streamInfo); } } - foreach (StreamInfo stream in streams) + foreach (var stream in streams) { stream.DeviceId = options.DeviceId; stream.DeviceProfileId = options.Profile.Id; @@ -97,7 +97,7 @@ namespace MediaBrowser.Model.Dlna { var sorted = SortMediaSources(streams, maxBitrate); - foreach (StreamInfo stream in sorted) + foreach (var stream in sorted) { return stream; } @@ -284,7 +284,7 @@ namespace MediaBrowser.Model.Dlna { var transcodeReasons = new List(); - StreamInfo playlistItem = new StreamInfo + var playlistItem = new StreamInfo { ItemId = options.ItemId, MediaType = DlnaProfileType.Audio, @@ -308,14 +308,14 @@ namespace MediaBrowser.Model.Dlna return playlistItem; } - MediaStream audioStream = item.GetDefaultAudioStream(null); + var audioStream = item.GetDefaultAudioStream(null); var directPlayInfo = GetAudioDirectPlayMethods(item, audioStream, options); var directPlayMethods = directPlayInfo.Item1; transcodeReasons.AddRange(directPlayInfo.Item2); - ConditionProcessor conditionProcessor = new ConditionProcessor(); + var conditionProcessor = new ConditionProcessor(); int? inputAudioChannels = audioStream == null ? null : audioStream.Channels; int? inputAudioBitrate = audioStream == null ? null : audioStream.BitDepth; @@ -328,12 +328,12 @@ namespace MediaBrowser.Model.Dlna // Make sure audio codec profiles are satisfied var conditions = new List(); - foreach (CodecProfile i in options.Profile.CodecProfiles) + foreach (var i in options.Profile.CodecProfiles) { if (i.Type == CodecType.Audio && i.ContainsAnyCodec(audioCodec, item.Container)) { bool applyConditions = true; - foreach (ProfileCondition applyCondition in i.ApplyConditions) + foreach (var applyCondition in i.ApplyConditions) { if (!conditionProcessor.IsAudioConditionSatisfied(applyCondition, inputAudioChannels, inputAudioBitrate, inputAudioSampleRate, inputAudioBitDepth)) { @@ -345,7 +345,7 @@ namespace MediaBrowser.Model.Dlna if (applyConditions) { - foreach (ProfileCondition c in i.Conditions) + foreach (var c in i.Conditions) { conditions.Add(c); } @@ -354,7 +354,7 @@ namespace MediaBrowser.Model.Dlna } bool all = true; - foreach (ProfileCondition c in conditions) + foreach (var c in conditions) { if (!conditionProcessor.IsAudioConditionSatisfied(c, inputAudioChannels, inputAudioBitrate, inputAudioSampleRate, inputAudioBitDepth)) { @@ -383,7 +383,7 @@ namespace MediaBrowser.Model.Dlna } TranscodingProfile transcodingProfile = null; - foreach (TranscodingProfile i in options.Profile.TranscodingProfiles) + foreach (var i in options.Profile.TranscodingProfiles) { if (i.Type == playlistItem.MediaType && i.Context == options.Context) { @@ -405,7 +405,7 @@ namespace MediaBrowser.Model.Dlna SetStreamInfoOptionsFromTranscodingProfile(playlistItem, transcodingProfile); var audioCodecProfiles = new List(); - foreach (CodecProfile i in options.Profile.CodecProfiles) + foreach (var i in options.Profile.CodecProfiles) { if (i.Type == CodecType.Audio && i.ContainsAnyCodec(transcodingProfile.AudioCodec, transcodingProfile.Container)) { @@ -416,10 +416,10 @@ namespace MediaBrowser.Model.Dlna } var audioTranscodingConditions = new List(); - foreach (CodecProfile i in audioCodecProfiles) + foreach (var i in audioCodecProfiles) { bool applyConditions = true; - foreach (ProfileCondition applyCondition in i.ApplyConditions) + foreach (var applyCondition in i.ApplyConditions) { if (!conditionProcessor.IsAudioConditionSatisfied(applyCondition, inputAudioChannels, inputAudioBitrate, inputAudioSampleRate, inputAudioBitDepth)) { @@ -431,7 +431,7 @@ namespace MediaBrowser.Model.Dlna if (applyConditions) { - foreach (ProfileCondition c in i.Conditions) + foreach (var c in i.Conditions) { audioTranscodingConditions.Add(c); } @@ -478,7 +478,7 @@ namespace MediaBrowser.Model.Dlna var transcodeReasons = new List(); DirectPlayProfile directPlayProfile = null; - foreach (DirectPlayProfile i in options.Profile.DirectPlayProfiles) + foreach (var i in options.Profile.DirectPlayProfiles) { if (i.Type == DlnaProfileType.Audio && IsAudioDirectPlaySupported(i, item, audioStream)) { @@ -607,7 +607,7 @@ namespace MediaBrowser.Model.Dlna { int highestScore = -1; - foreach (MediaStream stream in item.MediaStreams) + foreach (var stream in item.MediaStreams) { if (stream.Type == MediaStreamType.Subtitle && stream.Score.HasValue) { @@ -619,7 +619,7 @@ namespace MediaBrowser.Model.Dlna } var topStreams = new List(); - foreach (MediaStream stream in item.MediaStreams) + foreach (var stream in item.MediaStreams) { if (stream.Type == MediaStreamType.Subtitle && stream.Score.HasValue && stream.Score.Value == highestScore) { @@ -630,9 +630,9 @@ namespace MediaBrowser.Model.Dlna // If multiple streams have an equal score, try to pick the most efficient one if (topStreams.Count > 1) { - foreach (MediaStream stream in topStreams) + foreach (var stream in topStreams) { - foreach (SubtitleProfile profile in subtitleProfiles) + foreach (var profile in subtitleProfiles) { if (profile.Method == SubtitleDeliveryMethod.External && StringHelper.EqualsIgnoreCase(profile.Format, stream.Codec)) { @@ -705,7 +705,7 @@ namespace MediaBrowser.Model.Dlna var transcodeReasons = new List(); - StreamInfo playlistItem = new StreamInfo + var playlistItem = new StreamInfo { ItemId = options.ItemId, MediaType = DlnaProfileType.Video, @@ -716,15 +716,15 @@ namespace MediaBrowser.Model.Dlna }; playlistItem.SubtitleStreamIndex = options.SubtitleStreamIndex ?? GetDefaultSubtitleStreamIndex(item, options.Profile.SubtitleProfiles); - MediaStream subtitleStream = playlistItem.SubtitleStreamIndex.HasValue ? item.GetMediaStream(MediaStreamType.Subtitle, playlistItem.SubtitleStreamIndex.Value) : null; + var subtitleStream = playlistItem.SubtitleStreamIndex.HasValue ? item.GetMediaStream(MediaStreamType.Subtitle, playlistItem.SubtitleStreamIndex.Value) : null; - MediaStream audioStream = item.GetDefaultAudioStream(options.AudioStreamIndex ?? item.DefaultAudioStreamIndex); + var audioStream = item.GetDefaultAudioStream(options.AudioStreamIndex ?? item.DefaultAudioStreamIndex); if (audioStream != null) { playlistItem.AudioStreamIndex = audioStream.Index; } - MediaStream videoStream = item.VideoStream; + var videoStream = item.VideoStream; // TODO: This doesn't accout for situation of device being able to handle media bitrate, but wifi connection not fast enough var directPlayEligibilityResult = IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options, true) ?? 0, subtitleStream, options, PlayMethod.DirectPlay); @@ -751,7 +751,7 @@ namespace MediaBrowser.Model.Dlna if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, directPlay.Value, _transcoderSupport, item.Container, null); + var subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, directPlay.Value, _transcoderSupport, item.Container, null); playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method; playlistItem.SubtitleFormat = subtitleProfile.Format; @@ -775,7 +775,7 @@ namespace MediaBrowser.Model.Dlna // Can't direct play, find the transcoding profile TranscodingProfile transcodingProfile = null; - foreach (TranscodingProfile i in options.Profile.TranscodingProfiles) + foreach (var i in options.Profile.TranscodingProfiles) { if (i.Type == playlistItem.MediaType && i.Context == options.Context) { @@ -793,7 +793,7 @@ namespace MediaBrowser.Model.Dlna if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, PlayMethod.Transcode, _transcoderSupport, transcodingProfile.Container, transcodingProfile.Protocol); + var subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, PlayMethod.Transcode, _transcoderSupport, transcodingProfile.Container, transcodingProfile.Protocol); playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method; playlistItem.SubtitleFormat = subtitleProfile.Format; @@ -804,15 +804,15 @@ namespace MediaBrowser.Model.Dlna SetStreamInfoOptionsFromTranscodingProfile(playlistItem, transcodingProfile); - ConditionProcessor conditionProcessor = new ConditionProcessor(); + var conditionProcessor = new ConditionProcessor(); var isFirstAppliedCodecProfile = true; - foreach (CodecProfile i in options.Profile.CodecProfiles) + foreach (var i in options.Profile.CodecProfiles) { if (i.Type == CodecType.Video && i.ContainsAnyCodec(transcodingProfile.VideoCodec, transcodingProfile.Container)) { bool applyConditions = true; - foreach (ProfileCondition applyCondition in i.ApplyConditions) + foreach (var applyCondition in i.ApplyConditions) { int? width = videoStream == null ? null : videoStream.Width; int? height = videoStream == null ? null : videoStream.Height; @@ -863,12 +863,12 @@ namespace MediaBrowser.Model.Dlna playlistItem.AudioBitrate = Math.Min(playlistItem.AudioBitrate ?? audioBitrate, audioBitrate); isFirstAppliedCodecProfile = true; - foreach (CodecProfile i in options.Profile.CodecProfiles) + foreach (var i in options.Profile.CodecProfiles) { if (i.Type == CodecType.VideoAudio && i.ContainsAnyCodec(transcodingProfile.AudioCodec, transcodingProfile.Container)) { bool applyConditions = true; - foreach (ProfileCondition applyCondition in i.ApplyConditions) + foreach (var applyCondition in i.ApplyConditions) { bool? isSecondaryAudio = audioStream == null ? null : item.IsSecondaryAudio(audioStream); int? inputAudioBitrate = audioStream == null ? null : audioStream.BitRate; @@ -998,7 +998,7 @@ namespace MediaBrowser.Model.Dlna bool isEligibleForDirectPlay, bool isEligibleForDirectStream) { - DeviceProfile profile = options.Profile; + var profile = options.Profile; if (options.ForceDirectPlay) { @@ -1011,7 +1011,7 @@ namespace MediaBrowser.Model.Dlna // See if it can be direct played DirectPlayProfile directPlay = null; - foreach (DirectPlayProfile i in profile.DirectPlayProfiles) + foreach (var i in profile.DirectPlayProfiles) { if (i.Type == DlnaProfileType.Video && IsVideoDirectPlaySupported(i, mediaSource, videoStream, audioStream)) { @@ -1032,19 +1032,19 @@ namespace MediaBrowser.Model.Dlna string container = mediaSource.Container; var conditions = new List(); - foreach (ContainerProfile i in profile.ContainerProfiles) + foreach (var i in profile.ContainerProfiles) { if (i.Type == DlnaProfileType.Video && i.ContainsContainer(container)) { - foreach (ProfileCondition c in i.Conditions) + foreach (var c in i.Conditions) { conditions.Add(c); } } } - ConditionProcessor conditionProcessor = new ConditionProcessor(); + var conditionProcessor = new ConditionProcessor(); int? width = videoStream == null ? null : videoStream.Width; int? height = videoStream == null ? null : videoStream.Height; @@ -1072,7 +1072,7 @@ namespace MediaBrowser.Model.Dlna int? numVideoStreams = mediaSource.GetStreamCount(MediaStreamType.Video); // Check container conditions - foreach (ProfileCondition i in conditions) + foreach (var i in conditions) { if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isInterlaced, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc)) { @@ -1090,12 +1090,12 @@ namespace MediaBrowser.Model.Dlna string videoCodec = videoStream == null ? null : videoStream.Codec; conditions = new List(); - foreach (CodecProfile i in profile.CodecProfiles) + foreach (var i in profile.CodecProfiles) { if (i.Type == CodecType.Video && i.ContainsAnyCodec(videoCodec, container)) { bool applyConditions = true; - foreach (ProfileCondition applyCondition in i.ApplyConditions) + foreach (var applyCondition in i.ApplyConditions) { if (!conditionProcessor.IsVideoConditionSatisfied(applyCondition, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isInterlaced, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc)) { @@ -1107,7 +1107,7 @@ namespace MediaBrowser.Model.Dlna if (applyConditions) { - foreach (ProfileCondition c in i.Conditions) + foreach (var c in i.Conditions) { conditions.Add(c); } @@ -1115,7 +1115,7 @@ namespace MediaBrowser.Model.Dlna } } - foreach (ProfileCondition i in conditions) + foreach (var i in conditions) { if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isInterlaced, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc)) { @@ -1137,12 +1137,12 @@ namespace MediaBrowser.Model.Dlna conditions = new List(); bool? isSecondaryAudio = audioStream == null ? null : mediaSource.IsSecondaryAudio(audioStream); - foreach (CodecProfile i in profile.CodecProfiles) + foreach (var i in profile.CodecProfiles) { if (i.Type == CodecType.VideoAudio && i.ContainsAnyCodec(audioCodec, container)) { bool applyConditions = true; - foreach (ProfileCondition applyCondition in i.ApplyConditions) + foreach (var applyCondition in i.ApplyConditions) { if (!conditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, audioBitrate, audioSampleRate, audioBitDepth, audioProfile, isSecondaryAudio)) { @@ -1154,7 +1154,7 @@ namespace MediaBrowser.Model.Dlna if (applyConditions) { - foreach (ProfileCondition c in i.Conditions) + foreach (var c in i.Conditions) { conditions.Add(c); } @@ -1162,7 +1162,7 @@ namespace MediaBrowser.Model.Dlna } } - foreach (ProfileCondition i in conditions) + foreach (var i in conditions) { if (!conditionProcessor.IsVideoAudioConditionSatisfied(i, audioChannels, audioBitrate, audioSampleRate, audioBitDepth, audioProfile, isSecondaryAudio)) { @@ -1206,7 +1206,7 @@ namespace MediaBrowser.Model.Dlna { if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, playMethod, _transcoderSupport, item.Container, null); + var subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, playMethod, _transcoderSupport, item.Container, null); if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed) { @@ -1230,7 +1230,7 @@ namespace MediaBrowser.Model.Dlna if (!subtitleStream.IsExternal && (playMethod != PlayMethod.Transcode || !string.Equals(transcodingSubProtocol, "hls", StringComparison.OrdinalIgnoreCase))) { // Look for supported embedded subs of the same format - foreach (SubtitleProfile profile in subtitleProfiles) + foreach (var profile in subtitleProfiles) { if (!profile.SupportsLanguage(subtitleStream.Language)) { @@ -1259,7 +1259,7 @@ namespace MediaBrowser.Model.Dlna } // Look for supported embedded subs of a convertible format - foreach (SubtitleProfile profile in subtitleProfiles) + foreach (var profile in subtitleProfiles) { if (!profile.SupportsLanguage(subtitleStream.Language)) { @@ -1328,7 +1328,7 @@ namespace MediaBrowser.Model.Dlna private static SubtitleProfile GetExternalSubtitleProfile(MediaSourceInfo mediaSource, MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, PlayMethod playMethod, ITranscoderSupport transcoderSupport, bool allowConversion) { - foreach (SubtitleProfile profile in subtitleProfiles) + foreach (var profile in subtitleProfiles) { if (profile.Method != SubtitleDeliveryMethod.External && profile.Method != SubtitleDeliveryMethod.Hls) { @@ -1467,7 +1467,7 @@ namespace MediaBrowser.Model.Dlna private void ApplyTranscodingConditions(StreamInfo item, IEnumerable conditions, string qualifier, bool enableQualifiedConditions, bool enableNonQualifiedConditions) { - foreach (ProfileCondition condition in conditions) + foreach (var condition in conditions) { string value = condition.Value; diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 86d7c9d62..84bd1f429 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -145,8 +145,8 @@ namespace MediaBrowser.Model.Dlna throw new ArgumentNullException(nameof(baseUrl)); } - List list = new List(); - foreach (NameValuePair pair in BuildParams(this, accessToken)) + var list = new List(); + foreach (var pair in BuildParams(this, accessToken)) { if (string.IsNullOrEmpty(pair.Value)) { @@ -211,7 +211,7 @@ namespace MediaBrowser.Model.Dlna private static List BuildParams(StreamInfo item, string accessToken) { - List list = new List(); + var list = new List(); string audioCodecs = item.AudioCodecs.Length == 0 ? string.Empty : @@ -346,11 +346,11 @@ namespace MediaBrowser.Model.Dlna public List GetExternalSubtitles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken) { - List list = GetSubtitleProfiles(transcoderSupport, includeSelectedTrackOnly, enableAllProfiles, baseUrl, accessToken); - List newList = new List(); + var list = GetSubtitleProfiles(transcoderSupport, includeSelectedTrackOnly, enableAllProfiles, baseUrl, accessToken); + var newList = new List(); // First add the selected track - foreach (SubtitleStreamInfo stream in list) + foreach (var stream in list) { if (stream.DeliveryMethod == SubtitleDeliveryMethod.External) { @@ -368,7 +368,7 @@ namespace MediaBrowser.Model.Dlna public List GetSubtitleProfiles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken) { - List list = new List(); + var list = new List(); // HLS will preserve timestamps so we can just grab the full subtitle stream long startPositionTicks = StringHelper.EqualsIgnoreCase(SubProtocol, "hls") @@ -378,7 +378,7 @@ namespace MediaBrowser.Model.Dlna // First add the selected track if (SubtitleStreamIndex.HasValue) { - foreach (MediaStream stream in MediaSource.MediaStreams) + foreach (var stream in MediaSource.MediaStreams) { if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value) { @@ -389,7 +389,7 @@ namespace MediaBrowser.Model.Dlna if (!includeSelectedTrackOnly) { - foreach (MediaStream stream in MediaSource.MediaStreams) + foreach (var stream in MediaSource.MediaStreams) { if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value)) { @@ -405,16 +405,16 @@ namespace MediaBrowser.Model.Dlna { if (enableAllProfiles) { - foreach (SubtitleProfile profile in DeviceProfile.SubtitleProfiles) + foreach (var profile in DeviceProfile.SubtitleProfiles) { - SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, new[] { profile }, transcoderSupport); + var info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, new[] { profile }, transcoderSupport); list.Add(info); } } else { - SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, DeviceProfile.SubtitleProfiles, transcoderSupport); + var info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, DeviceProfile.SubtitleProfiles, transcoderSupport); list.Add(info); } @@ -422,8 +422,8 @@ namespace MediaBrowser.Model.Dlna private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, string baseUrl, string accessToken, long startPositionTicks, SubtitleProfile[] subtitleProfiles, ITranscoderSupport transcoderSupport) { - SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(MediaSource, stream, subtitleProfiles, PlayMethod, transcoderSupport, Container, SubProtocol); - SubtitleStreamInfo info = new SubtitleStreamInfo + var subtitleProfile = StreamBuilder.GetSubtitleProfile(MediaSource, stream, subtitleProfiles, PlayMethod, transcoderSupport, Container, SubProtocol); + var info = new SubtitleStreamInfo { IsForced = stream.IsForced, Language = stream.Language, @@ -502,7 +502,7 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream stream = TargetAudioStream; + var stream = TargetAudioStream; return stream == null ? null : stream.SampleRate; } } @@ -584,7 +584,7 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream stream = TargetVideoStream; + var stream = TargetVideoStream; return MaxFramerate.HasValue && !IsDirectStream ? MaxFramerate : stream == null ? null : stream.AverageFrameRate ?? stream.RealFrameRate; @@ -689,7 +689,7 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream stream = TargetVideoStream; + var stream = TargetVideoStream; return !IsDirectStream ? null : stream == null ? null : stream.PacketLength; @@ -727,7 +727,7 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream stream = TargetVideoStream; + var stream = TargetVideoStream; return !IsDirectStream ? null : stream == null ? null : stream.CodecTag; @@ -741,7 +741,7 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream stream = TargetAudioStream; + var stream = TargetAudioStream; return AudioBitrate.HasValue && !IsDirectStream ? AudioBitrate : stream == null ? null : stream.BitRate; @@ -797,7 +797,7 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream stream = TargetAudioStream; + var stream = TargetAudioStream; string inputCodec = stream == null ? null : stream.Codec; @@ -822,7 +822,7 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream stream = TargetVideoStream; + var stream = TargetVideoStream; string inputCodec = stream == null ? null : stream.Codec; @@ -878,7 +878,7 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream stream = TargetVideoStream; + var stream = TargetVideoStream; return VideoBitrate.HasValue && !IsDirectStream ? VideoBitrate @@ -890,7 +890,7 @@ namespace MediaBrowser.Model.Dlna { get { - TransportStreamTimestamp defaultValue = StringHelper.EqualsIgnoreCase(Container, "m2ts") + var defaultValue = StringHelper.EqualsIgnoreCase(Container, "m2ts") ? TransportStreamTimestamp.Valid : TransportStreamTimestamp.None; @@ -955,11 +955,11 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream videoStream = TargetVideoStream; + var videoStream = TargetVideoStream; if (videoStream != null && videoStream.Width.HasValue && videoStream.Height.HasValue) { - ImageSize size = new ImageSize + var size = new ImageSize { Width = videoStream.Width.Value, Height = videoStream.Height.Value @@ -968,7 +968,7 @@ namespace MediaBrowser.Model.Dlna double? maxWidth = MaxWidth.HasValue ? (double)MaxWidth.Value : (double?)null; double? maxHeight = MaxHeight.HasValue ? (double)MaxHeight.Value : (double?)null; - ImageSize newSize = DrawingUtils.Resize(size, + var newSize = DrawingUtils.Resize(size, 0, 0, maxWidth ?? 0, @@ -985,11 +985,11 @@ namespace MediaBrowser.Model.Dlna { get { - MediaStream videoStream = TargetVideoStream; + var videoStream = TargetVideoStream; if (videoStream != null && videoStream.Width.HasValue && videoStream.Height.HasValue) { - ImageSize size = new ImageSize + var size = new ImageSize { Width = videoStream.Width.Value, Height = videoStream.Height.Value @@ -998,7 +998,7 @@ namespace MediaBrowser.Model.Dlna double? maxWidth = MaxWidth.HasValue ? (double)MaxWidth.Value : (double?)null; double? maxHeight = MaxHeight.HasValue ? (double)MaxHeight.Value : (double?)null; - ImageSize newSize = DrawingUtils.Resize(size, + var newSize = DrawingUtils.Resize(size, 0, 0, maxWidth ?? 0, @@ -1059,9 +1059,9 @@ namespace MediaBrowser.Model.Dlna public List GetSelectableStreams(MediaStreamType type) { - List list = new List(); + var list = new List(); - foreach (MediaStream stream in MediaSource.MediaStreams) + foreach (var stream in MediaSource.MediaStreams) { if (type == stream.Type) { diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index c2219dc33..92e40fb01 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -120,7 +120,7 @@ namespace MediaBrowser.Model.Dto { var val = defaultIndex.Value; - foreach (MediaStream i in MediaStreams) + foreach (var i in MediaStreams) { if (i.Type == MediaStreamType.Audio && i.Index == val) { @@ -129,7 +129,7 @@ namespace MediaBrowser.Model.Dto } } - foreach (MediaStream i in MediaStreams) + foreach (var i in MediaStreams) { if (i.Type == MediaStreamType.Audio && i.IsDefault) { @@ -137,7 +137,7 @@ namespace MediaBrowser.Model.Dto } } - foreach (MediaStream i in MediaStreams) + foreach (var i in MediaStreams) { if (i.Type == MediaStreamType.Audio) { @@ -153,7 +153,7 @@ namespace MediaBrowser.Model.Dto { get { - foreach (MediaStream i in MediaStreams) + foreach (var i in MediaStreams) { if (i.Type == MediaStreamType.Video) { @@ -167,7 +167,7 @@ namespace MediaBrowser.Model.Dto public MediaStream GetMediaStream(MediaStreamType type, int index) { - foreach (MediaStream i in MediaStreams) + foreach (var i in MediaStreams) { if (i.Type == type && i.Index == index) { @@ -183,7 +183,7 @@ namespace MediaBrowser.Model.Dto int numMatches = 0; int numStreams = 0; - foreach (MediaStream i in MediaStreams) + foreach (var i in MediaStreams) { numStreams++; if (i.Type == type) @@ -203,7 +203,7 @@ namespace MediaBrowser.Model.Dto public bool? IsSecondaryAudio(MediaStream stream) { // Look for the first audio track marked as default - foreach (MediaStream currentStream in MediaStreams) + foreach (var currentStream in MediaStreams) { if (currentStream.Type == MediaStreamType.Audio && currentStream.IsDefault) { @@ -215,7 +215,7 @@ namespace MediaBrowser.Model.Dto } // Look for the first audio track - foreach (MediaStream currentStream in MediaStreams) + foreach (var currentStream in MediaStreams) { if (currentStream.Type == MediaStreamType.Audio) { diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index b51942af8..e0c3bead1 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -76,7 +76,7 @@ namespace MediaBrowser.Model.Entities // return AddLanguageIfNeeded(Title); //} - List attributes = new List(); + var attributes = new List(); if (!string.IsNullOrEmpty(Language)) { @@ -109,7 +109,7 @@ namespace MediaBrowser.Model.Entities if (Type == MediaStreamType.Video) { - List attributes = new List(); + var attributes = new List(); var resolutionText = GetResolutionText(); @@ -133,7 +133,7 @@ namespace MediaBrowser.Model.Entities // return AddLanguageIfNeeded(Title); //} - List attributes = new List(); + var attributes = new List(); if (!string.IsNullOrEmpty(Language)) { diff --git a/MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs b/MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs index edede8ba9..a5ae7c7a5 100644 --- a/MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs +++ b/MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Model.MediaInfo DirectPlayProtocols = new MediaProtocol[] { MediaProtocol.Http }; - VideoOptions videoOptions = options as VideoOptions; + var videoOptions = options as VideoOptions; if (videoOptions != null) { AudioStreamIndex = videoOptions.AudioStreamIndex; diff --git a/MediaBrowser.Model/Net/MimeTypes.cs b/MediaBrowser.Model/Net/MimeTypes.cs index e5d1ab462..77cba0f71 100644 --- a/MediaBrowser.Model/Net/MimeTypes.cs +++ b/MediaBrowser.Model/Net/MimeTypes.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Model.Net private static Dictionary GetVideoFileExtensionsDictionary() { - Dictionary dict = new Dictionary(StringComparer.OrdinalIgnoreCase); + var dict = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (string ext in VideoFileExtensions) { @@ -65,7 +65,7 @@ namespace MediaBrowser.Model.Net private static Dictionary GetMimeTypeLookup() { - Dictionary dict = new Dictionary(StringComparer.OrdinalIgnoreCase); + var dict = new Dictionary(StringComparer.OrdinalIgnoreCase); dict.Add(".jpg", "image/jpeg"); dict.Add(".jpeg", "image/jpeg"); diff --git a/MediaBrowser.Model/Notifications/NotificationOptions.cs b/MediaBrowser.Model/Notifications/NotificationOptions.cs index f48b5ee7f..cf8555423 100644 --- a/MediaBrowser.Model/Notifications/NotificationOptions.cs +++ b/MediaBrowser.Model/Notifications/NotificationOptions.cs @@ -77,7 +77,7 @@ namespace MediaBrowser.Model.Notifications public NotificationOption GetOptions(string type) { - foreach (NotificationOption i in Options) + foreach (var i in Options) { if (StringHelper.EqualsIgnoreCase(type, i.Type)) return i; } @@ -86,14 +86,14 @@ namespace MediaBrowser.Model.Notifications public bool IsEnabled(string type) { - NotificationOption opt = GetOptions(type); + var opt = GetOptions(type); return opt != null && opt.Enabled; } public bool IsServiceEnabled(string service, string notificationType) { - NotificationOption opt = GetOptions(notificationType); + var opt = GetOptions(notificationType); return opt == null || !ListHelper.ContainsIgnoreCase(opt.DisabledServices, service); @@ -101,7 +101,7 @@ namespace MediaBrowser.Model.Notifications public bool IsEnabledToMonitorUser(string type, Guid userId) { - NotificationOption opt = GetOptions(type); + var opt = GetOptions(type); return opt != null && opt.Enabled && !ListHelper.ContainsIgnoreCase(opt.DisabledMonitorUsers, userId.ToString("")); @@ -109,7 +109,7 @@ namespace MediaBrowser.Model.Notifications public bool IsEnabledToSendToUser(string type, string userId, UserPolicy userPolicy) { - NotificationOption opt = GetOptions(type); + var opt = GetOptions(type); if (opt != null && opt.Enabled) { diff --git a/MediaBrowser.Model/Services/HttpUtility.cs b/MediaBrowser.Model/Services/HttpUtility.cs index 98882e114..be180334c 100644 --- a/MediaBrowser.Model/Services/HttpUtility.cs +++ b/MediaBrowser.Model/Services/HttpUtility.cs @@ -445,8 +445,8 @@ namespace MediaBrowser.Model.Services if (s.IndexOf('&') == -1) return s; - StringBuilder entity = new StringBuilder(); - StringBuilder output = new StringBuilder(); + var entity = new StringBuilder(); + var output = new StringBuilder(); int len = s.Length; // 0 -> nothing, // 1 -> right after '&' @@ -623,7 +623,7 @@ namespace MediaBrowser.Model.Services if (query[0] == '?') query = query.Substring(1); - QueryParamCollection result = new QueryParamCollection(); + var result = new QueryParamCollection(); ParseQueryString(query, encoding, result); return result; } diff --git a/MediaBrowser.Model/System/IEnvironmentInfo.cs b/MediaBrowser.Model/System/IEnvironmentInfo.cs index 757d3c949..3ffcc7de1 100644 --- a/MediaBrowser.Model/System/IEnvironmentInfo.cs +++ b/MediaBrowser.Model/System/IEnvironmentInfo.cs @@ -4,7 +4,7 @@ namespace MediaBrowser.Model.System { public interface IEnvironmentInfo { - MediaBrowser.Model.System.OperatingSystem OperatingSystem { get; } + OperatingSystem OperatingSystem { get; } string OperatingSystemName { get; } string OperatingSystemVersion { get; } Architecture SystemArchitecture { get; } diff --git a/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs b/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs index 2b73fdcd3..b87f688e1 100644 --- a/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs @@ -132,7 +132,7 @@ namespace Priority_Queue int parent = node.QueueIndex / 2; while (parent >= 1) { - TItem parentNode = _nodes[parent]; + var parentNode = _nodes[parent]; if (HasHigherPriority(parentNode, node)) break; @@ -163,7 +163,7 @@ namespace Priority_Queue break; } - TItem childLeft = _nodes[childLeftIndex]; + var childLeft = _nodes[childLeftIndex]; if (HasHigherPriority(childLeft, newParent)) { newParent = childLeft; @@ -173,7 +173,7 @@ namespace Priority_Queue int childRightIndex = childLeftIndex + 1; if (childRightIndex <= _numNodes) { - TItem childRight = _nodes[childRightIndex]; + var childRight = _nodes[childRightIndex]; if (HasHigherPriority(childRight, newParent)) { newParent = childRight; @@ -234,7 +234,7 @@ namespace Priority_Queue } #endif - TItem returnMe = _nodes[1]; + var returnMe = _nodes[1]; Remove(returnMe); item = returnMe; return true; @@ -316,7 +316,7 @@ namespace Priority_Queue { //Bubble the updated node up or down as appropriate int parentIndex = node.QueueIndex / 2; - TItem parentNode = _nodes[parentIndex]; + var parentNode = _nodes[parentIndex]; if (parentIndex > 0 && HasHigherPriority(node, parentNode)) { @@ -356,7 +356,7 @@ namespace Priority_Queue } //Swap the node with the last node - TItem formerLastNode = _nodes[_numNodes]; + var formerLastNode = _nodes[_numNodes]; Swap(node, formerLastNode); _nodes[_numNodes] = null; _numNodes--; diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index 616086406..d0d00ef12 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -63,7 +63,7 @@ namespace MediaBrowser.Providers.Manager /// Index of the image. /// The cancellation token. /// Task. - /// mimeType + /// mimeType public Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken) { return SaveImage(item, source, mimeType, type, imageIndex, null, cancellationToken); @@ -299,7 +299,7 @@ namespace MediaBrowser.Providers.Manager /// The type. /// Index of the image. /// System.String. - /// + /// /// imageIndex /// or /// imageIndex @@ -316,7 +316,7 @@ namespace MediaBrowser.Providers.Manager /// The type. /// Index of the image. /// The path. - /// imageIndex + /// imageIndex /// or /// imageIndex private void SetImagePath(BaseItem item, ImageType type, int? imageIndex, string path) @@ -333,7 +333,7 @@ namespace MediaBrowser.Providers.Manager /// Type of the MIME. /// if set to true [save locally]. /// System.String. - /// + /// /// imageIndex /// or /// imageIndex @@ -490,7 +490,7 @@ namespace MediaBrowser.Providers.Manager /// Index of the image. /// Type of the MIME. /// IEnumerable{System.String}. - /// imageIndex + /// imageIndex private string[] GetCompatibleSavePaths(BaseItem item, ImageType type, int? imageIndex, string mimeType) { var season = item as Season; diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 3322582cc..1972ad290 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -415,7 +415,7 @@ namespace MediaBrowser.Providers.Manager var folder = item as Folder; if (folder != null && folder.SupportsDateLastMediaAdded) { - DateTime dateLastMediaAdded = DateTime.MinValue; + var dateLastMediaAdded = DateTime.MinValue; var any = false; foreach (var child in children) diff --git a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs index 9cfd5ab5c..71e979e2c 100644 --- a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs @@ -80,7 +80,7 @@ namespace Priority_Queue throw new InvalidOperationException("Cannot call .First on an empty queue"); } - SimpleNode first = _queue.First; + var first = _queue.First; return (first != null ? first.Data : default(TItem)); } } @@ -155,7 +155,7 @@ namespace Priority_Queue { lock (_queue) { - SimpleNode node = new SimpleNode(item); + var node = new SimpleNode(item); if (_queue.Count == _queue.MaxSize) { _queue.Resize(_queue.MaxSize * 2 + 1); @@ -199,7 +199,7 @@ namespace Priority_Queue { try { - SimpleNode updateMe = GetExistingNode(item); + var updateMe = GetExistingNode(item); _queue.UpdatePriority(updateMe, priority); } catch (InvalidOperationException ex) @@ -211,7 +211,7 @@ namespace Priority_Queue public IEnumerator GetEnumerator() { - List queueData = new List(); + var queueData = new List(); lock (_queue) { //Copy to a separate list because we don't want to 'yield return' inside a lock diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index ef5c781dc..88d9a346b 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -140,7 +140,7 @@ namespace MediaBrowser.Providers.Movies return _tmdbSettings; } - using (HttpResponseInfo response = await GetMovieDbResponse(new HttpRequestOptions + using (var response = await GetMovieDbResponse(new HttpRequestOptions { Url = string.Format(TmdbConfigUrl, ApiKey), CancellationToken = cancellationToken, @@ -148,7 +148,7 @@ namespace MediaBrowser.Providers.Movies }).ConfigureAwait(false)) { - using (Stream json = response.Content) + using (var json = response.Content) { _tmdbSettings = await _jsonSerializer.DeserializeFromStreamAsync(json).ConfigureAwait(false); diff --git a/MediaBrowser.Providers/Music/ArtistMetadataService.cs b/MediaBrowser.Providers/Music/ArtistMetadataService.cs index de9551f83..5b8782554 100644 --- a/MediaBrowser.Providers/Music/ArtistMetadataService.cs +++ b/MediaBrowser.Providers/Music/ArtistMetadataService.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Providers.Music protected override IList GetChildrenForMetadataUpdates(MusicArtist item) { return item.IsAccessedByName ? - item.GetTaggedItems(new Controller.Entities.InternalItemsQuery + item.GetTaggedItems(new InternalItemsQuery { Recursive = true, IsFolder = false diff --git a/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs b/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs index 8592b5c67..4e6d223a7 100644 --- a/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs @@ -50,7 +50,7 @@ namespace MediaBrowser.Providers.Omdb if (!string.IsNullOrWhiteSpace(imdbId)) { - OmdbProvider.RootObject rootObject = await provider.GetRootObject(imdbId, cancellationToken).ConfigureAwait(false); + var rootObject = await provider.GetRootObject(imdbId, cancellationToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(rootObject.Poster)) { diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index c9018a42c..618e5eb2d 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Providers.Omdb throw new ArgumentNullException(nameof(imdbId)); } - T item = itemResult.Item; + var item = itemResult.Item; var result = await GetRootObject(imdbId, cancellationToken).ConfigureAwait(false); @@ -113,7 +113,7 @@ namespace MediaBrowser.Providers.Omdb throw new ArgumentNullException(nameof(seriesImdbId)); } - T item = itemResult.Item; + var item = itemResult.Item; var seasonResult = await GetSeasonRootObject(seriesImdbId, seasonNumber, cancellationToken).ConfigureAwait(false); @@ -220,7 +220,7 @@ namespace MediaBrowser.Providers.Omdb string resultString; - using (Stream stream = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read)) + using (var stream = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read)) { using (var reader = new StreamReader(stream, new UTF8Encoding(false))) { @@ -239,7 +239,7 @@ namespace MediaBrowser.Providers.Omdb string resultString; - using (Stream stream = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read)) + using (var stream = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read)) { using (var reader = new StreamReader(stream, new UTF8Encoding(false))) { @@ -394,7 +394,7 @@ namespace MediaBrowser.Providers.Omdb private void ParseAdditionalMetadata(MetadataResult itemResult, RootObject result) where T : BaseItem { - T item = itemResult.Item; + var item = itemResult.Item; var isConfiguredForEnglish = IsConfiguredForEnglish(item) || _configurationManager.Configuration.EnableNewOmdbSupport; diff --git a/MediaBrowser.Providers/People/MovieDbPersonProvider.cs b/MediaBrowser.Providers/People/MovieDbPersonProvider.cs index 8fc5f40f8..9d9d8fef3 100644 --- a/MediaBrowser.Providers/People/MovieDbPersonProvider.cs +++ b/MediaBrowser.Providers/People/MovieDbPersonProvider.cs @@ -265,7 +265,7 @@ namespace MediaBrowser.Providers.People public class PersonSearchResult { /// - /// Gets or sets a value indicating whether this is adult. + /// Gets or sets a value indicating whether this is adult. /// /// true if adult; otherwise, false. public bool Adult { get; set; } @@ -300,7 +300,7 @@ namespace MediaBrowser.Providers.People /// Gets or sets the results. /// /// The results. - public List Results { get; set; } + public List Results { get; set; } /// /// Gets or sets the total_ pages. /// diff --git a/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs b/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs index 2f2d8eaeb..89c4acf04 100644 --- a/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs +++ b/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs @@ -131,7 +131,7 @@ namespace MediaBrowser.Providers.Playlists private IEnumerable GetWplItems(Stream stream) { - WplContent content = new WplContent(); + var content = new WplContent(); var playlist = content.GetFromStream(stream); return playlist.PlaylistEntries.Select(i => new LinkedChild diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index 0c7fe1e0f..544cfba0d 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -245,7 +245,7 @@ namespace MediaBrowser.Providers.Subtitles { if (video.VideoType != VideoType.VideoFile) { - return Task.FromResult(new RemoteSubtitleInfo[] { }); + return Task.FromResult(new RemoteSubtitleInfo[] { }); } VideoContentType mediaType; @@ -261,7 +261,7 @@ namespace MediaBrowser.Providers.Subtitles else { // These are the only supported types - return Task.FromResult(new RemoteSubtitleInfo[] { }); + return Task.FromResult(new RemoteSubtitleInfo[] { }); } var request = new SubtitleSearchRequest diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index f4fe6ee27..958312633 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -1118,7 +1118,7 @@ namespace MediaBrowser.Providers.TV private void FetchDataFromSeriesNode(MetadataResult result, XmlReader reader, CancellationToken cancellationToken) { - Series item = result.Item; + var item = result.Item; reader.MoveToContent(); reader.Read(); diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 55b49d273..3744df9b4 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -54,7 +54,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers /// The item. /// The metadata file. /// The cancellation token. - /// + /// /// public void Fetch(MetadataResult item, string metadataFile, CancellationToken cancellationToken) { @@ -225,7 +225,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers protected void ParseProviderLinks(T item, string xml) { //Look for a match for the Regex pattern "tt" followed by 7 digits - Match m = Regex.Match(xml, @"tt([0-9]{7})", RegexOptions.IgnoreCase); + var m = Regex.Match(xml, @"tt([0-9]{7})", RegexOptions.IgnoreCase); if (m.Success) { item.SetProviderId(MetadataProviders.Imdb, m.Value); @@ -379,7 +379,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers { MetadataFields field; - if (Enum.TryParse(i, true, out field)) + if (Enum.TryParse(i, true, out field)) { return (MetadataFields?)field; } diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index efc6b3358..1efffff3d 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -229,7 +229,7 @@ namespace MediaBrowser.XbmcMetadata.Savers CloseOutput = false }; - using (XmlWriter writer = XmlWriter.Create(stream, settings)) + using (var writer = XmlWriter.Create(stream, settings)) { var root = GetRootElementName(item); diff --git a/Mono.Nat/Mapping.cs b/Mono.Nat/Mapping.cs index 438068934..5b15d4e14 100644 --- a/Mono.Nat/Mapping.cs +++ b/Mono.Nat/Mapping.cs @@ -102,7 +102,7 @@ namespace Mono.Nat public override bool Equals(object obj) { - Mapping other = obj as Mapping; + var other = obj as Mapping; return other == null ? false : this.protocol == other.protocol && this.privatePort == other.privatePort && this.publicPort == other.publicPort; } diff --git a/Mono.Nat/Pmp/PmpNatDevice.cs b/Mono.Nat/Pmp/PmpNatDevice.cs index 9398e2bf9..95bd72a6c 100644 --- a/Mono.Nat/Pmp/PmpNatDevice.cs +++ b/Mono.Nat/Pmp/PmpNatDevice.cs @@ -66,7 +66,7 @@ namespace Mono.Nat.Pmp public override bool Equals(object obj) { - PmpNatDevice device = obj as PmpNatDevice; + var device = obj as PmpNatDevice; return (device == null) ? false : this.Equals(device); } diff --git a/Mono.Nat/Pmp/PmpSearcher.cs b/Mono.Nat/Pmp/PmpSearcher.cs index 5e4155841..cbd0d3686 100644 --- a/Mono.Nat/Pmp/PmpSearcher.cs +++ b/Mono.Nat/Pmp/PmpSearcher.cs @@ -81,14 +81,14 @@ namespace Mono.Nat try { - foreach (NetworkInterface n in NetworkInterface.GetAllNetworkInterfaces()) + foreach (var n in NetworkInterface.GetAllNetworkInterfaces()) { if (n.OperationalStatus != OperationalStatus.Up && n.OperationalStatus != OperationalStatus.Unknown) continue; - IPInterfaceProperties properties = n.GetIPProperties(); - List gatewayList = new List(); + var properties = n.GetIPProperties(); + var gatewayList = new List(); - foreach (GatewayIPAddressInformation gateway in properties.GatewayAddresses) + foreach (var gateway in properties.GatewayAddresses) { if (gateway.Address.AddressFamily == AddressFamily.InterNetwork) { @@ -120,7 +120,7 @@ namespace Mono.Nat if (gatewayList.Count > 0) { - foreach (UnicastIPAddressInformation address in properties.UnicastAddresses) + foreach (var address in properties.UnicastAddresses) { if (address.Address.AddressFamily == AddressFamily.InterNetwork) { @@ -150,7 +150,7 @@ namespace Mono.Nat public async void Search() { - foreach (UdpClient s in sockets) + foreach (var s in sockets) { try { @@ -181,7 +181,7 @@ namespace Mono.Nat // The nat-pmp search message. Must be sent to GatewayIP:53531 byte[] buffer = new byte[] { PmpConstants.Version, PmpConstants.OperationCode }; - foreach (IPEndPoint gatewayEndpoint in gatewayLists[client]) + foreach (var gatewayEndpoint in gatewayLists[client]) { await client.SendAsync(buffer, buffer.Length, gatewayEndpoint).ConfigureAwait(false); } @@ -189,8 +189,8 @@ namespace Mono.Nat bool IsSearchAddress(IPAddress address) { - foreach (List gatewayList in gatewayLists.Values) - foreach (IPEndPoint gatewayEndpoint in gatewayList) + foreach (var gatewayList in gatewayLists.Values) + foreach (var gatewayEndpoint in gatewayList) if (gatewayEndpoint.Address.Equals(address)) return true; return false; @@ -210,7 +210,7 @@ namespace Mono.Nat if (errorcode != 0) _logger.LogDebug("Non zero error: {0}", errorcode); - IPAddress publicIp = new IPAddress(new byte[] { response[8], response[9], response[10], response[11] }); + var publicIp = new IPAddress(new byte[] { response[8], response[9], response[10], response[11] }); nextSearch = DateTime.Now.AddMinutes(5); timeout = 250; diff --git a/Mono.Nat/Upnp/Messages/Requests/CreatePortMappingMessage.cs b/Mono.Nat/Upnp/Messages/Requests/CreatePortMappingMessage.cs index 5a2ab009a..217095e49 100644 --- a/Mono.Nat/Upnp/Messages/Requests/CreatePortMappingMessage.cs +++ b/Mono.Nat/Upnp/Messages/Requests/CreatePortMappingMessage.cs @@ -54,10 +54,10 @@ namespace Mono.Nat.Upnp public override HttpRequestOptions Encode() { - CultureInfo culture = CultureInfo.InvariantCulture; + var culture = CultureInfo.InvariantCulture; - StringBuilder builder = new StringBuilder(256); - XmlWriter writer = CreateWriter(builder); + var builder = new StringBuilder(256); + var writer = CreateWriter(builder); WriteFullElement(writer, "NewRemoteHost", string.Empty); WriteFullElement(writer, "NewExternalPort", this.mapping.PublicPort.ToString(culture)); diff --git a/Mono.Nat/Upnp/Messages/UpnpMessage.cs b/Mono.Nat/Upnp/Messages/UpnpMessage.cs index e734db8f4..1151dd997 100644 --- a/Mono.Nat/Upnp/Messages/UpnpMessage.cs +++ b/Mono.Nat/Upnp/Messages/UpnpMessage.cs @@ -91,7 +91,7 @@ namespace Mono.Nat.Upnp protected XmlWriter CreateWriter(StringBuilder sb) { - XmlWriterSettings settings = new XmlWriterSettings(); + var settings = new XmlWriterSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; return XmlWriter.Create(sb, settings); } diff --git a/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs b/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs index 57ecdeca9..b70768b6f 100644 --- a/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs +++ b/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs @@ -82,7 +82,7 @@ namespace Mono.Nat * prefix. */ // We have an internet gateway device now - UpnpNatDevice d = new UpnpNatDevice(localAddress, deviceInfo, endpoint, string.Empty, _logger, _httpClient); + var d = new UpnpNatDevice(localAddress, deviceInfo, endpoint, string.Empty, _logger, _httpClient); await d.GetServicesList().ConfigureAwait(false); diff --git a/Mono.Nat/Upnp/UpnpNatDevice.cs b/Mono.Nat/Upnp/UpnpNatDevice.cs index f37d6dd0c..63a28ebdc 100644 --- a/Mono.Nat/Upnp/UpnpNatDevice.cs +++ b/Mono.Nat/Upnp/UpnpNatDevice.cs @@ -109,8 +109,8 @@ namespace Mono.Nat.Upnp int abortCount = 0; int bytesRead = 0; byte[] buffer = new byte[10240]; - StringBuilder servicesXml = new StringBuilder(); - XmlDocument xmldoc = new XmlDocument(); + var servicesXml = new StringBuilder(); + var xmldoc = new XmlDocument(); using (var s = response.Content) { @@ -144,9 +144,9 @@ namespace Mono.Nat.Upnp } } - XmlNamespaceManager ns = new XmlNamespaceManager(xmldoc.NameTable); + var ns = new XmlNamespaceManager(xmldoc.NameTable); ns.AddNamespace("ns", "urn:schemas-upnp-org:device-1-0"); - XmlNodeList nodes = xmldoc.SelectNodes("//*/ns:serviceList", ns); + var nodes = xmldoc.SelectNodes("//*/ns:serviceList", ns); foreach (XmlNode node in nodes) { @@ -169,7 +169,7 @@ namespace Mono.Nat.Upnp { if (u.IsAbsoluteUri) { - EndPoint old = hostEndPoint; + var old = hostEndPoint; IPAddress parsedHostIpAddress; if (IPAddress.TryParse(u.Host, out parsedHostIpAddress)) { @@ -228,7 +228,7 @@ namespace Mono.Nat.Upnp public override async Task CreatePortMap(Mapping mapping) { - CreatePortMappingMessage message = new CreatePortMappingMessage(mapping, localAddress, this); + var message = new CreatePortMappingMessage(mapping, localAddress, this); using (await _httpClient.SendAsync(message.Encode(), message.Method).ConfigureAwait(false)) { @@ -237,7 +237,7 @@ namespace Mono.Nat.Upnp public override bool Equals(object obj) { - UpnpNatDevice device = obj as UpnpNatDevice; + var device = obj as UpnpNatDevice; return (device == null) ? false : this.Equals((device)); } diff --git a/OpenSubtitlesHandler/Console/OSHConsole.cs b/OpenSubtitlesHandler/Console/OSHConsole.cs index 586377e53..396b28cbc 100644 --- a/OpenSubtitlesHandler/Console/OSHConsole.cs +++ b/OpenSubtitlesHandler/Console/OSHConsole.cs @@ -58,7 +58,7 @@ namespace OpenSubtitlesHandler.Console /// /// Console Debug Args /// - public class DebugEventArgs : System.EventArgs + public class DebugEventArgs : EventArgs { public DebugCode Code { get; private set; } public string Text { get; private set; } diff --git a/OpenSubtitlesHandler/MovieHasher.cs b/OpenSubtitlesHandler/MovieHasher.cs index 5a93edd5c..25d91c1ac 100644 --- a/OpenSubtitlesHandler/MovieHasher.cs +++ b/OpenSubtitlesHandler/MovieHasher.cs @@ -37,7 +37,7 @@ namespace OpenSubtitlesHandler public static string ToHexadecimal(byte[] bytes) { - StringBuilder hexBuilder = new StringBuilder(); + var hexBuilder = new StringBuilder(); for (int i = 0; i < bytes.Length; i++) { hexBuilder.Append(bytes[i].ToString("x2")); diff --git a/OpenSubtitlesHandler/OpenSubtitles.cs b/OpenSubtitlesHandler/OpenSubtitles.cs index 4a44ccde3..ddf2e83e8 100644 --- a/OpenSubtitlesHandler/OpenSubtitles.cs +++ b/OpenSubtitlesHandler/OpenSubtitles.cs @@ -57,12 +57,12 @@ namespace OpenSubtitlesHandler public static IMethodResponse LogIn(string userName, string password, string language) { // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(userName)); parms.Add(new XmlRpcValueBasic(password)); parms.Add(new XmlRpcValueBasic(language)); parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT)); - XmlRpcMethodCall call = new XmlRpcMethodCall("LogIn", parms); + var call = new XmlRpcMethodCall("LogIn", parms); OSHConsole.WriteLine("Sending LogIn request to the server ...", DebugCode.Good); //File.WriteAllText(".\\request.txt", Encoding.UTF8.GetString(XmlRpcGenerator.Generate(call))); @@ -77,9 +77,9 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; - MethodResponseLogIn re = new MethodResponseLogIn("Success", "Log in successful."); - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var re = new MethodResponseLogIn("Success", "Log in successful."); + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -103,12 +103,12 @@ namespace OpenSubtitlesHandler public static async Task LogInAsync(string userName, string password, string language, CancellationToken cancellationToken) { // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(userName)); parms.Add(new XmlRpcValueBasic(password)); parms.Add(new XmlRpcValueBasic(language)); parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT)); - XmlRpcMethodCall call = new XmlRpcMethodCall("LogIn", parms); + var call = new XmlRpcMethodCall("LogIn", parms); OSHConsole.WriteLine("Sending LogIn request to the server ...", DebugCode.Good); //File.WriteAllText(".\\request.txt", Encoding.UTF8.GetString(XmlRpcGenerator.Generate(call))); @@ -126,9 +126,9 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; - MethodResponseLogIn re = new MethodResponseLogIn("Success", "Log in successful."); - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var re = new MethodResponseLogIn("Success", "Log in successful."); + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -170,9 +170,9 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); - XmlRpcMethodCall call = new XmlRpcMethodCall("LogOut", parms); + var call = new XmlRpcMethodCall("LogOut", parms); OSHConsole.WriteLine("Sending LogOut request to the server ...", DebugCode.Good); // Send the request to the server @@ -185,10 +185,10 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct strct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var strct = (XmlRpcValueStruct)calls[0].Parameters[0]; OSHConsole.WriteLine("STATUS=" + ((XmlRpcValueBasic)strct.Members[0].Data).Data.ToString()); OSHConsole.WriteLine("SECONDS=" + ((XmlRpcValueBasic)strct.Members[1].Data).Data.ToString()); - MethodResponseLogIn re = new MethodResponseLogIn("Success", "Log out successful."); + var re = new MethodResponseLogIn("Success", "Log out successful."); re.Status = ((XmlRpcValueBasic)strct.Members[0].Data).Data.ToString(); re.Seconds = (double)((XmlRpcValueBasic)strct.Members[1].Data).Data; return re; @@ -214,10 +214,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT, XmlRpcBasicValueType.String)); - XmlRpcMethodCall call = new XmlRpcMethodCall("NoOperation", parms); + var call = new XmlRpcMethodCall("NoOperation", parms); OSHConsole.WriteLine("Sending NoOperation request to the server ...", DebugCode.Good); // Send the request to the server @@ -230,18 +230,18 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - MethodResponseNoOperation R = new MethodResponseNoOperation(); - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var R = new MethodResponseNoOperation(); + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data); break; case "download_limits": - XmlRpcValueStruct dlStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (XmlRpcStructMember dlmember in dlStruct.Members) + var dlStruct = (XmlRpcValueStruct)MEMBER.Data; + foreach (var dlmember in dlStruct.Members) { OSHConsole.WriteLine(" >" + dlmember.Name + "= " + dlmember.Data.Data.ToString()); switch (dlmember.Name) @@ -292,16 +292,16 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "No subtitle search parameter passed"); } // Method call .. - List parms = new List(); + var parms = new List(); // Add token param parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Add subtitle search parameters. Each one will be like 'array' of structs. - XmlRpcValueArray array = new XmlRpcValueArray(); - foreach (SubtitleSearchParameters param in parameters) + var array = new XmlRpcValueArray(); + foreach (var param in parameters) { - XmlRpcValueStruct strct = new XmlRpcValueStruct(new List()); + var strct = new XmlRpcValueStruct(new List()); // sublanguageid member - XmlRpcStructMember member = new XmlRpcStructMember("sublanguageid", + var member = new XmlRpcStructMember("sublanguageid", new XmlRpcValueBasic(param.SubLangaugeID, XmlRpcBasicValueType.String)); strct.Members.Add(member); // moviehash member @@ -345,7 +345,7 @@ namespace OpenSubtitlesHandler // Add the array to the parameters parms.Add(array); // Call ! - XmlRpcMethodCall call = new XmlRpcMethodCall("SearchSubtitles", parms); + var call = new XmlRpcMethodCall("SearchSubtitles", parms); OSHConsole.WriteLine("Sending SearchSubtitles request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT)); @@ -362,11 +362,11 @@ namespace OpenSubtitlesHandler //* the first is status //* the second is [array of structs, each one includes subtitle file]. //* the third is [double basic value] represent seconds token by server. - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseSubtitleSearch R = new MethodResponseSubtitleSearch(); + var R = new MethodResponseSubtitleSearch(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -384,14 +384,14 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine("Search results: "); - XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (IXmlRpcValue subStruct in rarray.Values) + var rarray = (XmlRpcValueArray)MEMBER.Data; + foreach (var subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; - SubtitleSearchResult result = new SubtitleSearchResult(); - foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) + var result = new SubtitleSearchResult(); + foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -472,16 +472,16 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "No subtitle search parameter passed"); } // Method call .. - List parms = new List(); + var parms = new List(); // Add token param parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Add subtitle search parameters. Each one will be like 'array' of structs. - XmlRpcValueArray array = new XmlRpcValueArray(); - foreach (SubtitleSearchParameters param in parameters) + var array = new XmlRpcValueArray(); + foreach (var param in parameters) { - XmlRpcValueStruct strct = new XmlRpcValueStruct(new List()); + var strct = new XmlRpcValueStruct(new List()); // sublanguageid member - XmlRpcStructMember member = new XmlRpcStructMember("sublanguageid", + var member = new XmlRpcStructMember("sublanguageid", new XmlRpcValueBasic(param.SubLangaugeID, XmlRpcBasicValueType.String)); strct.Members.Add(member); // moviehash member @@ -525,7 +525,7 @@ namespace OpenSubtitlesHandler // Add the array to the parameters parms.Add(array); // Call ! - XmlRpcMethodCall call = new XmlRpcMethodCall("SearchSubtitles", parms); + var call = new XmlRpcMethodCall("SearchSubtitles", parms); OSHConsole.WriteLine("Sending SearchSubtitles request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(await Utilities.SendRequestAsync(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT, cancellationToken).ConfigureAwait(false)); @@ -542,11 +542,11 @@ namespace OpenSubtitlesHandler //* the first is status //* the second is [array of structs, each one includes subtitle file]. //* the third is [double basic value] represent seconds token by server. - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseSubtitleSearch R = new MethodResponseSubtitleSearch(); + var R = new MethodResponseSubtitleSearch(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -564,14 +564,14 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine("Search results: "); - XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (IXmlRpcValue subStruct in rarray.Values) + var rarray = (XmlRpcValueArray)MEMBER.Data; + foreach (var subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; - SubtitleSearchResult result = new SubtitleSearchResult(); - foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) + var result = new SubtitleSearchResult(); + foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -657,11 +657,11 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "No subtitle id passed"); } // Method call .. - List parms = new List(); + var parms = new List(); // Add token param parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Add subtitle search parameters. Each one will be like 'array' of structs. - XmlRpcValueArray array = new XmlRpcValueArray(); + var array = new XmlRpcValueArray(); foreach (int id in subIDS) { array.Values.Add(new XmlRpcValueBasic(id, XmlRpcBasicValueType.Int)); @@ -669,7 +669,7 @@ namespace OpenSubtitlesHandler // Add the array to the parameters parms.Add(array); // Call ! - XmlRpcMethodCall call = new XmlRpcMethodCall("DownloadSubtitles", parms); + var call = new XmlRpcMethodCall("DownloadSubtitles", parms); OSHConsole.WriteLine("Sending DownloadSubtitles request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT)); @@ -685,12 +685,12 @@ namespace OpenSubtitlesHandler //* the first is status //* the second is [array of structs, each one includes subtitle file]. //* the third is [double basic value] represent seconds token by server. - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseSubtitleDownload R = new MethodResponseSubtitleDownload(); + var R = new MethodResponseSubtitleDownload(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -707,14 +707,14 @@ namespace OpenSubtitlesHandler if (MEMBER.Data is XmlRpcValueArray) { OSHConsole.WriteLine("Download results:"); - XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (IXmlRpcValue subStruct in rarray.Values) + var rarray = (XmlRpcValueArray)MEMBER.Data; + foreach (var subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; - SubtitleDownloadResult result = new SubtitleDownloadResult(); - foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) + var result = new SubtitleDownloadResult(); + foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -764,11 +764,11 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "No subtitle id passed"); } // Method call .. - List parms = new List(); + var parms = new List(); // Add token param parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Add subtitle search parameters. Each one will be like 'array' of structs. - XmlRpcValueArray array = new XmlRpcValueArray(); + var array = new XmlRpcValueArray(); foreach (int id in subIDS) { array.Values.Add(new XmlRpcValueBasic(id, XmlRpcBasicValueType.Int)); @@ -776,7 +776,7 @@ namespace OpenSubtitlesHandler // Add the array to the parameters parms.Add(array); // Call ! - XmlRpcMethodCall call = new XmlRpcMethodCall("DownloadSubtitles", parms); + var call = new XmlRpcMethodCall("DownloadSubtitles", parms); OSHConsole.WriteLine("Sending DownloadSubtitles request to the server ...", DebugCode.Good); // Send the request to the server @@ -795,12 +795,12 @@ namespace OpenSubtitlesHandler //* the first is status //* the second is [array of structs, each one includes subtitle file]. //* the third is [double basic value] represent seconds token by server. - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseSubtitleDownload R = new MethodResponseSubtitleDownload(); + var R = new MethodResponseSubtitleDownload(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -817,14 +817,14 @@ namespace OpenSubtitlesHandler if (MEMBER.Data is XmlRpcValueArray) { OSHConsole.WriteLine("Download results:"); - XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (IXmlRpcValue subStruct in rarray.Values) + var rarray = (XmlRpcValueArray)MEMBER.Data; + foreach (var subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; - SubtitleDownloadResult result = new SubtitleDownloadResult(); - foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) + var result = new SubtitleDownloadResult(); + foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -879,15 +879,15 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "No subtitle id passed"); } // Method call .. - List parms = new List(); + var parms = new List(); // Add token param parms.Add(new XmlRpcValueBasic(TOKEN)); // Add subtitle search parameters. Each one will be like 'array' of structs. - XmlRpcValueArray array = new XmlRpcValueArray(subIDS); + var array = new XmlRpcValueArray(subIDS); // Add the array to the parameters parms.Add(array); // Call ! - XmlRpcMethodCall call = new XmlRpcMethodCall("GetComments", parms); + var call = new XmlRpcMethodCall("GetComments", parms); OSHConsole.WriteLine("Sending GetComments request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT)); @@ -899,12 +899,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseGetComments R = new MethodResponseGetComments(); + var R = new MethodResponseGetComments(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -921,14 +921,14 @@ namespace OpenSubtitlesHandler if (MEMBER.Data is XmlRpcValueArray) { OSHConsole.WriteLine("Comments results:"); - XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (IXmlRpcValue commentStruct in rarray.Values) + var rarray = (XmlRpcValueArray)MEMBER.Data; + foreach (var commentStruct in rarray.Values) { if (commentStruct == null) continue; if (!(commentStruct is XmlRpcValueStruct)) continue; - GetCommentsResult result = new GetCommentsResult(); - foreach (XmlRpcStructMember commentmember in ((XmlRpcValueStruct)commentStruct).Members) + var result = new GetCommentsResult(); + foreach (var commentmember in ((XmlRpcValueStruct)commentStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (commentmember.Name) @@ -977,22 +977,22 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Array of sub langs - XmlRpcValueArray a = new XmlRpcValueArray(languageIDS); + var a = new XmlRpcValueArray(languageIDS); parms.Add(a); // Array of video parameters a = new XmlRpcValueArray(); - foreach (SearchToMailMovieParameter p in movies) + foreach (var p in movies) { - XmlRpcValueStruct str = new XmlRpcValueStruct(new List()); + var str = new XmlRpcValueStruct(new List()); str.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash))); str.Members.Add(new XmlRpcStructMember("moviesize", new XmlRpcValueBasic(p.moviesize))); a.Values.Add(str); } parms.Add(a); - XmlRpcMethodCall call = new XmlRpcMethodCall("SearchToMail", parms); + var call = new XmlRpcMethodCall("SearchToMail", parms); OSHConsole.WriteLine("Sending SearchToMail request to the server ...", DebugCode.Good); // Send the request to the server @@ -1005,12 +1005,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseSearchToMail R = new MethodResponseSearchToMail(); + var R = new MethodResponseSearchToMail(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1044,13 +1044,13 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); // Add token param parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Add query param parms.Add(new XmlRpcValueBasic(query, XmlRpcBasicValueType.String)); // Call ! - XmlRpcMethodCall call = new XmlRpcMethodCall("SearchMoviesOnIMDB", parms); + var call = new XmlRpcMethodCall("SearchMoviesOnIMDB", parms); OSHConsole.WriteLine("Sending SearchMoviesOnIMDB request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT)); @@ -1062,12 +1062,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseMovieSearch R = new MethodResponseMovieSearch(); + var R = new MethodResponseMovieSearch(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -1084,14 +1084,14 @@ namespace OpenSubtitlesHandler if (MEMBER.Data is XmlRpcValueArray) { OSHConsole.WriteLine("Search results:"); - XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (IXmlRpcValue subStruct in rarray.Values) + var rarray = (XmlRpcValueArray)MEMBER.Data; + foreach (var subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; - MovieSearchResult result = new MovieSearchResult(); - foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) + var result = new MovieSearchResult(); + foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -1135,13 +1135,13 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); // Add token param parms.Add(new XmlRpcValueBasic(TOKEN)); // Add query param parms.Add(new XmlRpcValueBasic(imdbid)); // Call ! - XmlRpcMethodCall call = new XmlRpcMethodCall("GetIMDBMovieDetails", parms); + var call = new XmlRpcMethodCall("GetIMDBMovieDetails", parms); OSHConsole.WriteLine("Sending GetIMDBMovieDetails request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT)); @@ -1153,12 +1153,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseMovieDetails R = new MethodResponseMovieDetails(); + var R = new MethodResponseMovieDetails(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -1176,8 +1176,8 @@ namespace OpenSubtitlesHandler if (MEMBER.Data is XmlRpcValueStruct) { OSHConsole.WriteLine("Details result:"); - XmlRpcValueStruct detailsStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (XmlRpcStructMember dmem in detailsStruct.Members) + var detailsStruct = (XmlRpcValueStruct)MEMBER.Data; + foreach (var dmem in detailsStruct.Members) { switch (dmem.Name) { @@ -1193,8 +1193,8 @@ namespace OpenSubtitlesHandler case "cast": // this is another struct with cast members... OSHConsole.WriteLine(">" + dmem.Name + "= "); - XmlRpcValueStruct castStruct = (XmlRpcValueStruct)dmem.Data; - foreach (XmlRpcStructMember castMemeber in castStruct.Members) + var castStruct = (XmlRpcValueStruct)dmem.Data; + foreach (var castMemeber in castStruct.Members) { R.Cast.Add(castMemeber.Data.Data.ToString()); OSHConsole.WriteLine(" >" + castMemeber.Data.Data.ToString()); @@ -1203,8 +1203,8 @@ namespace OpenSubtitlesHandler case "directors": OSHConsole.WriteLine(">" + dmem.Name + "= "); // this is another struct with directors members... - XmlRpcValueStruct directorsStruct = (XmlRpcValueStruct)dmem.Data; - foreach (XmlRpcStructMember directorsMember in directorsStruct.Members) + var directorsStruct = (XmlRpcValueStruct)dmem.Data; + foreach (var directorsMember in directorsStruct.Members) { R.Directors.Add(directorsMember.Data.Data.ToString()); OSHConsole.WriteLine(" >" + directorsMember.Data.Data.ToString()); @@ -1213,8 +1213,8 @@ namespace OpenSubtitlesHandler case "writers": OSHConsole.WriteLine(">" + dmem.Name + "= "); // this is another struct with writers members... - XmlRpcValueStruct writersStruct = (XmlRpcValueStruct)dmem.Data; - foreach (XmlRpcStructMember writersMember in writersStruct.Members) + var writersStruct = (XmlRpcValueStruct)dmem.Data; + foreach (var writersMember in writersStruct.Members) { R.Writers.Add(writersMember.Data.Data.ToString()); OSHConsole.WriteLine("+->" + writersMember.Data.Data.ToString()); @@ -1222,7 +1222,7 @@ namespace OpenSubtitlesHandler break; case "awards": // this is an array of genres... - XmlRpcValueArray awardsArray = (XmlRpcValueArray)dmem.Data; + var awardsArray = (XmlRpcValueArray)dmem.Data; foreach (XmlRpcValueBasic award in awardsArray.Values) { R.Awards.Add(award.Data.ToString()); @@ -1232,7 +1232,7 @@ namespace OpenSubtitlesHandler case "genres": OSHConsole.WriteLine(">" + dmem.Name + "= "); // this is an array of genres... - XmlRpcValueArray genresArray = (XmlRpcValueArray)dmem.Data; + var genresArray = (XmlRpcValueArray)dmem.Data; foreach (XmlRpcValueBasic genre in genresArray.Values) { R.Genres.Add(genre.Data.ToString()); @@ -1242,7 +1242,7 @@ namespace OpenSubtitlesHandler case "country": OSHConsole.WriteLine(">" + dmem.Name + "= "); // this is an array of country... - XmlRpcValueArray countryArray = (XmlRpcValueArray)dmem.Data; + var countryArray = (XmlRpcValueArray)dmem.Data; foreach (XmlRpcValueBasic country in countryArray.Values) { R.Country.Add(country.Data.ToString()); @@ -1252,7 +1252,7 @@ namespace OpenSubtitlesHandler case "language": OSHConsole.WriteLine(">" + dmem.Name + "= "); // this is an array of language... - XmlRpcValueArray languageArray = (XmlRpcValueArray)dmem.Data; + var languageArray = (XmlRpcValueArray)dmem.Data; foreach (XmlRpcValueBasic language in languageArray.Values) { R.Language.Add(language.Data.ToString()); @@ -1262,7 +1262,7 @@ namespace OpenSubtitlesHandler case "certification": OSHConsole.WriteLine(">" + dmem.Name + "= "); // this is an array of certification... - XmlRpcValueArray certificationArray = (XmlRpcValueArray)dmem.Data; + var certificationArray = (XmlRpcValueArray)dmem.Data; foreach (XmlRpcValueBasic certification in certificationArray.Values) { R.Certification.Add(certification.Data.ToString()); @@ -1304,16 +1304,16 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); // Add token param parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Add movieinfo struct - XmlRpcValueStruct movieinfo = new XmlRpcValueStruct(new List()); + var movieinfo = new XmlRpcValueStruct(new List()); movieinfo.Members.Add(new XmlRpcStructMember("moviename", new XmlRpcValueBasic(movieName))); movieinfo.Members.Add(new XmlRpcStructMember("movieyear", new XmlRpcValueBasic(movieyear))); parms.Add(movieinfo); // Call ! - XmlRpcMethodCall call = new XmlRpcMethodCall("InsertMovie", parms); + var call = new XmlRpcMethodCall("InsertMovie", parms); OSHConsole.WriteLine("Sending InsertMovie request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT)); @@ -1325,12 +1325,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseInsertMovie R = new MethodResponseInsertMovie(); + var R = new MethodResponseInsertMovie(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -1373,11 +1373,11 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); - foreach (InsertMovieHashParameters p in parameters) + foreach (var p in parameters) { - XmlRpcValueStruct pstruct = new XmlRpcValueStruct(new List()); + var pstruct = new XmlRpcValueStruct(new List()); pstruct.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash))); pstruct.Members.Add(new XmlRpcStructMember("moviebytesize", new XmlRpcValueBasic(p.moviebytesize))); pstruct.Members.Add(new XmlRpcStructMember("imdbid", new XmlRpcValueBasic(p.imdbid))); @@ -1386,7 +1386,7 @@ namespace OpenSubtitlesHandler pstruct.Members.Add(new XmlRpcStructMember("moviefilename", new XmlRpcValueBasic(p.moviefilename))); parms.Add(pstruct); } - XmlRpcMethodCall call = new XmlRpcMethodCall("InsertMovieHash", parms); + var call = new XmlRpcMethodCall("InsertMovieHash", parms); OSHConsole.WriteLine("Sending InsertMovieHash request to the server ...", DebugCode.Good); // Send the request to the server @@ -1399,12 +1399,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseInsertMovieHash R = new MethodResponseInsertMovieHash(); + var R = new MethodResponseInsertMovieHash(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1417,14 +1417,14 @@ namespace OpenSubtitlesHandler OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": - XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (XmlRpcStructMember dataMember in dataStruct.Members) + var dataStruct = (XmlRpcValueStruct)MEMBER.Data; + foreach (var dataMember in dataStruct.Members) { switch (dataMember.Name) { case "accepted_moviehashes": - XmlRpcValueArray mh = (XmlRpcValueArray)dataMember.Data; - foreach (IXmlRpcValue val in mh.Values) + var mh = (XmlRpcValueArray)dataMember.Data; + foreach (var val in mh.Values) { if (val is XmlRpcValueBasic) { @@ -1433,8 +1433,8 @@ namespace OpenSubtitlesHandler } break; case "new_imdbs": - XmlRpcValueArray mi = (XmlRpcValueArray)dataMember.Data; - foreach (IXmlRpcValue val in mi.Values) + var mi = (XmlRpcValueArray)dataMember.Data; + foreach (var val in mi.Values) { if (val is XmlRpcValueBasic) { @@ -1472,10 +1472,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT, XmlRpcBasicValueType.String)); - XmlRpcMethodCall call = new XmlRpcMethodCall("ServerInfo", parms); + var call = new XmlRpcMethodCall("ServerInfo", parms); OSHConsole.WriteLine("Sending ServerInfo request to the server ...", DebugCode.Good); // Send the request to the server @@ -1488,12 +1488,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseServerInfo R = new MethodResponseServerInfo(); + var R = new MethodResponseServerInfo(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1568,8 +1568,8 @@ namespace OpenSubtitlesHandler case "last_update_strings": //R.total_subtitles_languages = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + ":"); - XmlRpcValueStruct luStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (XmlRpcStructMember luMemeber in luStruct.Members) + var luStruct = (XmlRpcValueStruct)MEMBER.Data; + foreach (var luMemeber in luStruct.Members) { R.last_update_strings.Add(luMemeber.Name + " [" + luMemeber.Data.Data.ToString() + "]"); OSHConsole.WriteLine(" >" + luMemeber.Name + "= " + luMemeber.Data.Data.ToString()); @@ -1602,10 +1602,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); parms.Add(new XmlRpcValueBasic(IDSubMovieFile, XmlRpcBasicValueType.String)); - XmlRpcMethodCall call = new XmlRpcMethodCall("ReportWrongMovieHash", parms); + var call = new XmlRpcMethodCall("ReportWrongMovieHash", parms); OSHConsole.WriteLine("Sending ReportWrongMovieHash request to the server ...", DebugCode.Good); // Send the request to the server @@ -1618,12 +1618,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseReportWrongMovieHash R = new MethodResponseReportWrongMovieHash(); + var R = new MethodResponseReportWrongMovieHash(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1666,14 +1666,14 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); - XmlRpcValueStruct s = new XmlRpcValueStruct(new List()); + var s = new XmlRpcValueStruct(new List()); s.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(moviehash))); s.Members.Add(new XmlRpcStructMember("moviebytesize", new XmlRpcValueBasic(moviebytesize))); s.Members.Add(new XmlRpcStructMember("imdbid", new XmlRpcValueBasic(imdbid))); parms.Add(s); - XmlRpcMethodCall call = new XmlRpcMethodCall("ReportWrongImdbMovie", parms); + var call = new XmlRpcMethodCall("ReportWrongImdbMovie", parms); OSHConsole.WriteLine("Sending ReportWrongImdbMovie request to the server ...", DebugCode.Good); // Send the request to the server @@ -1686,12 +1686,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseAddComment R = new MethodResponseAddComment(); + var R = new MethodResponseAddComment(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1725,13 +1725,13 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); - XmlRpcValueStruct s = new XmlRpcValueStruct(new List()); + var s = new XmlRpcValueStruct(new List()); s.Members.Add(new XmlRpcStructMember("idsubtitle", new XmlRpcValueBasic(idsubtitle))); s.Members.Add(new XmlRpcStructMember("score", new XmlRpcValueBasic(score))); parms.Add(s); - XmlRpcMethodCall call = new XmlRpcMethodCall("SubtitlesVote", parms); + var call = new XmlRpcMethodCall("SubtitlesVote", parms); OSHConsole.WriteLine("Sending SubtitlesVote request to the server ...", DebugCode.Good); // Send the request to the server @@ -1744,20 +1744,20 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseSubtitlesVote R = new MethodResponseSubtitlesVote(); + var R = new MethodResponseSubtitlesVote(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": - XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (XmlRpcStructMember dataMemeber in dataStruct.Members) + var dataStruct = (XmlRpcValueStruct)MEMBER.Data; + foreach (var dataMemeber in dataStruct.Members) { OSHConsole.WriteLine(" >" + dataMemeber.Name + "= " + dataMemeber.Data.Data.ToString()); switch (dataMemeber.Name) @@ -1797,14 +1797,14 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); - XmlRpcValueStruct s = new XmlRpcValueStruct(new List()); + var s = new XmlRpcValueStruct(new List()); s.Members.Add(new XmlRpcStructMember("idsubtitle", new XmlRpcValueBasic(idsubtitle))); s.Members.Add(new XmlRpcStructMember("comment", new XmlRpcValueBasic(comment))); s.Members.Add(new XmlRpcStructMember("badsubtitle", new XmlRpcValueBasic(badsubtitle))); parms.Add(s); - XmlRpcMethodCall call = new XmlRpcMethodCall("AddComment", parms); + var call = new XmlRpcMethodCall("AddComment", parms); OSHConsole.WriteLine("Sending AddComment request to the server ...", DebugCode.Good); // Send the request to the server @@ -1817,12 +1817,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseAddComment R = new MethodResponseAddComment(); + var R = new MethodResponseAddComment(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1857,14 +1857,14 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); - XmlRpcValueStruct s = new XmlRpcValueStruct(new List()); + var s = new XmlRpcValueStruct(new List()); s.Members.Add(new XmlRpcStructMember("sublanguageid", new XmlRpcValueBasic(sublanguageid))); s.Members.Add(new XmlRpcStructMember("idmovieimdb", new XmlRpcValueBasic(idmovieimdb))); s.Members.Add(new XmlRpcStructMember("comment", new XmlRpcValueBasic(comment))); parms.Add(s); - XmlRpcMethodCall call = new XmlRpcMethodCall("AddRequest", parms); + var call = new XmlRpcMethodCall("AddRequest", parms); OSHConsole.WriteLine("Sending AddRequest request to the server ...", DebugCode.Good); // Send the request to the server @@ -1877,20 +1877,20 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseAddRequest R = new MethodResponseAddRequest(); + var R = new MethodResponseAddRequest(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": - XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (XmlRpcStructMember dataMemeber in dataStruct.Members) + var dataStruct = (XmlRpcValueStruct)MEMBER.Data; + foreach (var dataMemeber in dataStruct.Members) { switch (dataMemeber.Name) { @@ -1926,10 +1926,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN)); parms.Add(new XmlRpcValueBasic(language)); - XmlRpcMethodCall call = new XmlRpcMethodCall("GetSubLanguages", parms); + var call = new XmlRpcMethodCall("GetSubLanguages", parms); OSHConsole.WriteLine("Sending GetSubLanguages request to the server ...", DebugCode.Good); // Send the request to the server @@ -1942,27 +1942,27 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseGetSubLanguages R = new MethodResponseGetSubLanguages(); + var R = new MethodResponseGetSubLanguages(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data":// array of structs - XmlRpcValueArray array = (XmlRpcValueArray)MEMBER.Data; - foreach (IXmlRpcValue value in array.Values) + var array = (XmlRpcValueArray)MEMBER.Data; + foreach (var value in array.Values) { if (value is XmlRpcValueStruct) { - XmlRpcValueStruct valueStruct = (XmlRpcValueStruct)value; - SubtitleLanguage lang = new SubtitleLanguage(); + var valueStruct = (XmlRpcValueStruct)value; + var lang = new SubtitleLanguage(); OSHConsole.WriteLine(">SubLanguage:"); - foreach (XmlRpcStructMember langMemeber in valueStruct.Members) + foreach (var langMemeber in valueStruct.Members) { OSHConsole.WriteLine(" >" + langMemeber.Name + "= " + langMemeber.Data.Data.ToString()); switch (langMemeber.Name) @@ -2009,10 +2009,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // We need to gzip texts then code them with base 24 - List decodedTexts = new List(); + var decodedTexts = new List(); foreach (string text in texts) { // compress @@ -2025,7 +2025,7 @@ namespace OpenSubtitlesHandler decodedTexts.Add(Convert.ToBase64String(data)); } parms.Add(new XmlRpcValueArray(decodedTexts.ToArray())); - XmlRpcMethodCall call = new XmlRpcMethodCall("DetectLanguage", parms); + var call = new XmlRpcMethodCall("DetectLanguage", parms); OSHConsole.WriteLine("Sending DetectLanguage request to the server ...", DebugCode.Good); // Send the request to the server @@ -2038,12 +2038,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseDetectLanguage R = new MethodResponseDetectLanguage(); + var R = new MethodResponseDetectLanguage(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2053,10 +2053,10 @@ namespace OpenSubtitlesHandler if (MEMBER.Data is XmlRpcValueStruct) { OSHConsole.WriteLine(">Languages:"); - XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (XmlRpcStructMember dataMember in dataStruct.Members) + var dataStruct = (XmlRpcValueStruct)MEMBER.Data; + foreach (var dataMember in dataStruct.Members) { - DetectLanguageResult lang = new DetectLanguageResult(); + var lang = new DetectLanguageResult(); lang.InputSample = dataMember.Name; lang.LanguageID = dataMember.Data.Data.ToString(); R.Results.Add(lang); @@ -2095,10 +2095,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN)); parms.Add(new XmlRpcValueBasic(program)); - XmlRpcMethodCall call = new XmlRpcMethodCall("GetAvailableTranslations", parms); + var call = new XmlRpcMethodCall("GetAvailableTranslations", parms); OSHConsole.WriteLine("Sending GetAvailableTranslations request to the server ...", DebugCode.Good); // Send the request to the server @@ -2111,29 +2111,29 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseGetAvailableTranslations R = new MethodResponseGetAvailableTranslations(); + var R = new MethodResponseGetAvailableTranslations(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": - XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data; + var dataStruct = (XmlRpcValueStruct)MEMBER.Data; OSHConsole.WriteLine(">data:"); - foreach (XmlRpcStructMember dataMember in dataStruct.Members) + foreach (var dataMember in dataStruct.Members) { if (dataMember.Data is XmlRpcValueStruct) { - XmlRpcValueStruct resStruct = (XmlRpcValueStruct)dataMember.Data; - GetAvailableTranslationsResult res = new GetAvailableTranslationsResult(); + var resStruct = (XmlRpcValueStruct)dataMember.Data; + var res = new GetAvailableTranslationsResult(); res.LanguageID = dataMember.Name; OSHConsole.WriteLine(" >LanguageID: " + dataMember.Name); - foreach (XmlRpcStructMember resMember in resStruct.Members) + foreach (var resMember in resStruct.Members) { switch (resMember.Name) { @@ -2178,12 +2178,12 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN)); parms.Add(new XmlRpcValueBasic(iso639)); parms.Add(new XmlRpcValueBasic(format)); parms.Add(new XmlRpcValueBasic(program)); - XmlRpcMethodCall call = new XmlRpcMethodCall("GetTranslation", parms); + var call = new XmlRpcMethodCall("GetTranslation", parms); OSHConsole.WriteLine("Sending GetTranslation request to the server ...", DebugCode.Good); // Send the request to the server @@ -2197,12 +2197,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseGetTranslation R = new MethodResponseGetTranslation(); + var R = new MethodResponseGetTranslation(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2236,12 +2236,12 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); }*/ // Method call .. - List parms = new List(); + var parms = new List(); // parms.Add(new XmlRpcValueBasic(TOKEN)); parms.Add(new XmlRpcValueBasic(program)); // parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT)); - XmlRpcMethodCall call = new XmlRpcMethodCall("AutoUpdate", parms); + var call = new XmlRpcMethodCall("AutoUpdate", parms); OSHConsole.WriteLine("Sending AutoUpdate request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT)); @@ -2253,12 +2253,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseAutoUpdate R = new MethodResponseAutoUpdate(); + var R = new MethodResponseAutoUpdate(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2296,10 +2296,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN)); parms.Add(new XmlRpcValueArray(hashes)); - XmlRpcMethodCall call = new XmlRpcMethodCall("CheckMovieHash", parms); + var call = new XmlRpcMethodCall("CheckMovieHash", parms); OSHConsole.WriteLine("Sending CheckMovieHash request to the server ...", DebugCode.Good); // Send the request to the server @@ -2312,27 +2312,27 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseCheckMovieHash R = new MethodResponseCheckMovieHash(); + var R = new MethodResponseCheckMovieHash(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": - XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data; + var dataStruct = (XmlRpcValueStruct)MEMBER.Data; OSHConsole.WriteLine(">Data:"); - foreach (XmlRpcStructMember dataMember in dataStruct.Members) + foreach (var dataMember in dataStruct.Members) { - CheckMovieHashResult res = new CheckMovieHashResult(); + var res = new CheckMovieHashResult(); res.Name = dataMember.Name; OSHConsole.WriteLine(" >" + res.Name + ":"); - XmlRpcValueStruct movieStruct = (XmlRpcValueStruct)dataMember.Data; - foreach (XmlRpcStructMember movieMember in movieStruct.Members) + var movieStruct = (XmlRpcValueStruct)dataMember.Data; + foreach (var movieMember in movieStruct.Members) { switch (movieMember.Name) { @@ -2373,10 +2373,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN)); parms.Add(new XmlRpcValueArray(hashes)); - XmlRpcMethodCall call = new XmlRpcMethodCall("CheckMovieHash2", parms); + var call = new XmlRpcMethodCall("CheckMovieHash2", parms); OSHConsole.WriteLine("Sending CheckMovieHash2 request to the server ...", DebugCode.Good); // Send the request to the server @@ -2389,31 +2389,31 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseCheckMovieHash2 R = new MethodResponseCheckMovieHash2(); + var R = new MethodResponseCheckMovieHash2(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": - XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data; + var dataStruct = (XmlRpcValueStruct)MEMBER.Data; OSHConsole.WriteLine(">Data:"); - foreach (XmlRpcStructMember dataMember in dataStruct.Members) + foreach (var dataMember in dataStruct.Members) { - CheckMovieHash2Result res = new CheckMovieHash2Result(); + var res = new CheckMovieHash2Result(); res.Name = dataMember.Name; OSHConsole.WriteLine(" >" + res.Name + ":"); - XmlRpcValueArray dataArray = (XmlRpcValueArray)dataMember.Data; + var dataArray = (XmlRpcValueArray)dataMember.Data; foreach (XmlRpcValueStruct movieStruct in dataArray.Values) { - CheckMovieHash2Data d = new CheckMovieHash2Data(); - foreach (XmlRpcStructMember movieMember in movieStruct.Members) + var d = new CheckMovieHash2Data(); + foreach (var movieMember in movieStruct.Members) { switch (movieMember.Name) { @@ -2459,10 +2459,10 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN)); parms.Add(new XmlRpcValueArray(hashes)); - XmlRpcMethodCall call = new XmlRpcMethodCall("CheckSubHash", parms); + var call = new XmlRpcMethodCall("CheckSubHash", parms); OSHConsole.WriteLine("Sending CheckSubHash request to the server ...", DebugCode.Good); // Send the request to the server @@ -2475,12 +2475,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseCheckSubHash R = new MethodResponseCheckSubHash(); + var R = new MethodResponseCheckSubHash(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2488,11 +2488,11 @@ namespace OpenSubtitlesHandler case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": OSHConsole.WriteLine(">Data:"); - XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (XmlRpcStructMember dataMember in dataStruct.Members) + var dataStruct = (XmlRpcValueStruct)MEMBER.Data; + foreach (var dataMember in dataStruct.Members) { OSHConsole.WriteLine(" >" + dataMember.Name + "= " + dataMember.Data.Data.ToString()); - CheckSubHashResult r = new CheckSubHashResult(); + var r = new CheckSubHashResult(); r.Hash = dataMember.Name; r.SubID = dataMember.Data.Data.ToString(); R.Results.Add(r); @@ -2526,14 +2526,14 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); - XmlRpcValueStruct s = new XmlRpcValueStruct(new List()); + var s = new XmlRpcValueStruct(new List()); int i = 1; - foreach (TryUploadSubtitlesParameters cd in subs) + foreach (var cd in subs) { - XmlRpcStructMember member = new XmlRpcStructMember("cd" + i, null); - XmlRpcValueStruct memberStruct = new XmlRpcValueStruct(new List()); + var member = new XmlRpcStructMember("cd" + i, null); + var memberStruct = new XmlRpcValueStruct(new List()); memberStruct.Members.Add(new XmlRpcStructMember("subhash", new XmlRpcValueBasic(cd.subhash))); memberStruct.Members.Add(new XmlRpcStructMember("subfilename", new XmlRpcValueBasic(cd.subfilename))); memberStruct.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(cd.moviehash))); @@ -2547,7 +2547,7 @@ namespace OpenSubtitlesHandler i++; } parms.Add(s); - XmlRpcMethodCall call = new XmlRpcMethodCall("TryUploadSubtitles", parms); + var call = new XmlRpcMethodCall("TryUploadSubtitles", parms); OSHConsole.WriteLine("Sending TryUploadSubtitles request to the server ...", DebugCode.Good); // Send the request to the server @@ -2560,12 +2560,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseTryUploadSubtitles R = new MethodResponseTryUploadSubtitles(); + var R = new MethodResponseTryUploadSubtitles(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2577,14 +2577,14 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine("Results: "); - XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (IXmlRpcValue subStruct in rarray.Values) + var rarray = (XmlRpcValueArray)MEMBER.Data; + foreach (var subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; - SubtitleSearchResult result = new SubtitleSearchResult(); - foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) + var result = new SubtitleSearchResult(); + foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -2658,14 +2658,14 @@ namespace OpenSubtitlesHandler return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first."); } // Method call .. - List parms = new List(); + var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN)); // Main struct - XmlRpcValueStruct s = new XmlRpcValueStruct(new List()); + var s = new XmlRpcValueStruct(new List()); // Base info member as struct - XmlRpcStructMember member = new XmlRpcStructMember("baseinfo", null); - XmlRpcValueStruct memberStruct = new XmlRpcValueStruct(new List()); + var member = new XmlRpcStructMember("baseinfo", null); + var memberStruct = new XmlRpcValueStruct(new List()); memberStruct.Members.Add(new XmlRpcStructMember("idmovieimdb", new XmlRpcValueBasic(info.idmovieimdb))); memberStruct.Members.Add(new XmlRpcStructMember("sublanguageid", new XmlRpcValueBasic(info.sublanguageid))); memberStruct.Members.Add(new XmlRpcStructMember("moviereleasename", new XmlRpcValueBasic(info.moviereleasename))); @@ -2679,10 +2679,10 @@ namespace OpenSubtitlesHandler // CDS members int i = 1; - foreach (UploadSubtitleParameters cd in info.CDS) + foreach (var cd in info.CDS) { - XmlRpcStructMember member2 = new XmlRpcStructMember("cd" + i, null); - XmlRpcValueStruct memberStruct2 = new XmlRpcValueStruct(new List()); + var member2 = new XmlRpcStructMember("cd" + i, null); + var memberStruct2 = new XmlRpcValueStruct(new List()); memberStruct2.Members.Add(new XmlRpcStructMember("subhash", new XmlRpcValueBasic(cd.subhash))); memberStruct2.Members.Add(new XmlRpcStructMember("subfilename", new XmlRpcValueBasic(cd.subfilename))); memberStruct2.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(cd.moviehash))); @@ -2701,7 +2701,7 @@ namespace OpenSubtitlesHandler parms.Add(s); // add user agent //parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT)); - XmlRpcMethodCall call = new XmlRpcMethodCall("UploadSubtitles", parms); + var call = new XmlRpcMethodCall("UploadSubtitles", parms); OSHConsole.WriteLine("Sending UploadSubtitles request to the server ...", DebugCode.Good); // Send the request to the server string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT)); @@ -2713,12 +2713,12 @@ namespace OpenSubtitlesHandler { if (calls[0].Parameters.Count > 0) { - XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; + var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // Create the response, we'll need it later - MethodResponseUploadSubtitles R = new MethodResponseUploadSubtitles(); + var R = new MethodResponseUploadSubtitles(); // To make sure response is not currepted by server, do it in loop - foreach (XmlRpcStructMember MEMBER in mainStruct.Members) + foreach (var MEMBER in mainStruct.Members) { switch (MEMBER.Name) { diff --git a/OpenSubtitlesHandler/Utilities.cs b/OpenSubtitlesHandler/Utilities.cs index 468fdd254..8ea0c546d 100644 --- a/OpenSubtitlesHandler/Utilities.cs +++ b/OpenSubtitlesHandler/Utilities.cs @@ -56,9 +56,9 @@ namespace OpenSubtitlesHandler /// Bytes array of decompressed data public static byte[] Decompress(Stream dataToDecompress) { - using (MemoryStream target = new MemoryStream()) + using (var target = new MemoryStream()) { - using (System.IO.Compression.GZipStream decompressionStream = new System.IO.Compression.GZipStream(dataToDecompress, System.IO.Compression.CompressionMode.Decompress)) + using (var decompressionStream = new System.IO.Compression.GZipStream(dataToDecompress, System.IO.Compression.CompressionMode.Decompress)) { decompressionStream.CopyTo(target); } @@ -116,7 +116,7 @@ namespace OpenSubtitlesHandler using (responseStream) { // Handle response, should be XML text. - List data = new List(); + var data = new List(); while (true) { int r = responseStream.ReadByte(); diff --git a/OpenSubtitlesHandler/XML-RPC/Values/XmlRpcValueArray.cs b/OpenSubtitlesHandler/XML-RPC/Values/XmlRpcValueArray.cs index 3303e3848..d10a80175 100644 --- a/OpenSubtitlesHandler/XML-RPC/Values/XmlRpcValueArray.cs +++ b/OpenSubtitlesHandler/XML-RPC/Values/XmlRpcValueArray.cs @@ -82,7 +82,7 @@ namespace XmlRpcHandler base() { values = new List(); - foreach (DateTime val in dates) + foreach (var val in dates) { values.Add(new XmlRpcValueBasic(val)); } @@ -91,7 +91,7 @@ namespace XmlRpcHandler base() { values = new List(); - foreach (XmlRpcValueBasic val in basicValues) + foreach (var val in basicValues) { values.Add(val); } @@ -100,7 +100,7 @@ namespace XmlRpcHandler base() { values = new List(); - foreach (XmlRpcValueStruct val in structs) + foreach (var val in structs) { values.Add(val); } @@ -109,7 +109,7 @@ namespace XmlRpcHandler base() { values = new List(); - foreach (XmlRpcValueArray val in arrays) + foreach (var val in arrays) { values.Add(val); } diff --git a/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs b/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs index 3d02622da..b1351f9e3 100644 --- a/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs +++ b/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs @@ -50,17 +50,17 @@ namespace XmlRpcHandler if (methods.Length == 0) throw new Exception("No method to write !"); // Create xml - XmlWriterSettings sett = new XmlWriterSettings(); + var sett = new XmlWriterSettings(); sett.Indent = true; sett.Encoding = Encoding.UTF8; using (var ms = new MemoryStream()) { - using (XmlWriter XMLwrt = XmlWriter.Create(ms, sett)) + using (var XMLwrt = XmlWriter.Create(ms, sett)) { // Let's write the methods - foreach (XmlRpcMethodCall method in methods) + foreach (var method in methods) { XMLwrt.WriteStartElement("methodCall");//methodCall XMLwrt.WriteStartElement("methodName");//methodName @@ -68,7 +68,7 @@ namespace XmlRpcHandler XMLwrt.WriteEndElement();//methodName XMLwrt.WriteStartElement("params");//params // Write values - foreach (IXmlRpcValue p in method.Parameters) + foreach (var p in method.Parameters) { XMLwrt.WriteStartElement("param");//param if (p is XmlRpcValueBasic) @@ -101,8 +101,8 @@ namespace XmlRpcHandler /// public static XmlRpcMethodCall[] DecodeMethodResponse(string xmlResponse) { - List methods = new List(); - XmlReaderSettings sett = new XmlReaderSettings(); + var methods = new List(); + var sett = new XmlReaderSettings(); sett.DtdProcessing = DtdProcessing.Ignore; sett.IgnoreWhitespace = true; MemoryStream str; @@ -116,15 +116,15 @@ namespace XmlRpcHandler } using (str) { - using (XmlReader XMLread = XmlReader.Create(str, sett)) + using (var XMLread = XmlReader.Create(str, sett)) { - XmlRpcMethodCall call = new XmlRpcMethodCall("methodResponse"); + var call = new XmlRpcMethodCall("methodResponse"); // Read parameters while (XMLread.Read()) { if (XMLread.Name == "param" && XMLread.IsStartElement()) { - IXmlRpcValue val = ReadValue(XMLread); + var val = ReadValue(XMLread); if (val != null) call.Parameters.Add(val); } @@ -169,7 +169,7 @@ namespace XmlRpcHandler // Get date time format if (val.Data != null) { - DateTime time = (DateTime)val.Data; + var time = (DateTime)val.Data; string dt = time.Year + time.Month.ToString("D2") + time.Day.ToString("D2") + "T" + time.Hour.ToString("D2") + ":" + time.Minute.ToString("D2") + ":" + time.Second.ToString("D2"); @@ -190,7 +190,7 @@ namespace XmlRpcHandler { XMLwrt.WriteStartElement("value");//value XMLwrt.WriteStartElement("struct");//struct - foreach (XmlRpcStructMember member in val.Members) + foreach (var member in val.Members) { XMLwrt.WriteStartElement("member");//member @@ -221,7 +221,7 @@ namespace XmlRpcHandler XMLwrt.WriteStartElement("value");//value XMLwrt.WriteStartElement("array");//array XMLwrt.WriteStartElement("data");//data - foreach (IXmlRpcValue o in val.Values) + foreach (var o in val.Values) { if (o is XmlRpcValueBasic) { @@ -283,7 +283,7 @@ namespace XmlRpcHandler int hour = int.Parse(date.Substring(9, 2), UsCulture); int minute = int.Parse(date.Substring(12, 2), UsCulture);//19980717T14:08:55 int sec = int.Parse(date.Substring(15, 2), UsCulture); - DateTime time = new DateTime(year, month, day, hour, minute, sec); + var time = new DateTime(year, month, day, hour, minute, sec); return new XmlRpcValueBasic(time, XmlRpcBasicValueType.dateTime_iso8601); } else if (xmlReader.Name == "base64" && xmlReader.IsStartElement()) @@ -293,17 +293,17 @@ namespace XmlRpcHandler } else if (xmlReader.Name == "struct" && xmlReader.IsStartElement()) { - XmlRpcValueStruct strct = new XmlRpcValueStruct(new List()); + var strct = new XmlRpcValueStruct(new List()); // Read members... while (xmlReader.Read()) { if (xmlReader.Name == "member" && xmlReader.IsStartElement()) { - XmlRpcStructMember member = new XmlRpcStructMember("", null); + var member = new XmlRpcStructMember("", null); xmlReader.Read();// read name member.Name = ReadString(xmlReader); - IXmlRpcValue val = ReadValue(xmlReader, true); + var val = ReadValue(xmlReader, true); if (val != null) { member.Data = val; @@ -319,7 +319,7 @@ namespace XmlRpcHandler } else if (xmlReader.Name == "array" && xmlReader.IsStartElement()) { - XmlRpcValueArray array = new XmlRpcValueArray(); + var array = new XmlRpcValueArray(); // Read members... while (xmlReader.Read()) { @@ -329,7 +329,7 @@ namespace XmlRpcHandler } else { - IXmlRpcValue val = ReadValue(xmlReader); + var val = ReadValue(xmlReader); if (val != null) array.Values.Add(val); } diff --git a/RSSDP/DeviceAvailableEventArgs.cs b/RSSDP/DeviceAvailableEventArgs.cs index e52e801c4..9106e27e5 100644 --- a/RSSDP/DeviceAvailableEventArgs.cs +++ b/RSSDP/DeviceAvailableEventArgs.cs @@ -7,7 +7,7 @@ using MediaBrowser.Model.Net; namespace Rssdp { /// - /// Event arguments for the event. + /// Event arguments for the event. /// public sealed class DeviceAvailableEventArgs : EventArgs { @@ -18,17 +18,17 @@ namespace Rssdp private readonly DiscoveredSsdpDevice _DiscoveredDevice; private readonly bool _IsNewlyDiscovered; - #endregion + #endregion - #region Constructors + #region Constructors - /// - /// Full constructor. - /// - /// A instance representing the available device. - /// A boolean value indicating whether or not this device came from the cache. See for more detail. - /// Thrown if the parameter is null. - public DeviceAvailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool isNewlyDiscovered) + /// + /// Full constructor. + /// + /// A instance representing the available device. + /// A boolean value indicating whether or not this device came from the cache. See for more detail. + /// Thrown if the parameter is null. + public DeviceAvailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool isNewlyDiscovered) { if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice)); @@ -48,10 +48,10 @@ namespace Rssdp get { return _IsNewlyDiscovered; } } - /// - /// A reference to a instance containing the discovered details and allowing access to the full device description. - /// - public DiscoveredSsdpDevice DiscoveredDevice + /// + /// A reference to a instance containing the discovered details and allowing access to the full device description. + /// + public DiscoveredSsdpDevice DiscoveredDevice { get { return _DiscoveredDevice; } } diff --git a/RSSDP/DeviceEventArgs.cs b/RSSDP/DeviceEventArgs.cs index 55b23b68c..3925ba248 100644 --- a/RSSDP/DeviceEventArgs.cs +++ b/RSSDP/DeviceEventArgs.cs @@ -22,7 +22,7 @@ namespace Rssdp /// Constructs a new instance for the specified . /// /// The associated with the event this argument class is being used for. - /// Thrown if the argument is null. + /// Thrown if the argument is null. public DeviceEventArgs(SsdpDevice device) { if (device == null) throw new ArgumentNullException(nameof(device)); diff --git a/RSSDP/DeviceUnavailableEventArgs.cs b/RSSDP/DeviceUnavailableEventArgs.cs index ecba7c013..d90ddfb60 100644 --- a/RSSDP/DeviceUnavailableEventArgs.cs +++ b/RSSDP/DeviceUnavailableEventArgs.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Rssdp { /// - /// Event arguments for the event. + /// Event arguments for the event. /// public sealed class DeviceUnavailableEventArgs : EventArgs { @@ -25,7 +25,7 @@ namespace Rssdp /// /// A instance representing the device that has become unavailable. /// A boolean value indicating whether this device is unavailable because it expired, or because it explicitly sent a byebye notification.. See for more detail. - /// Thrown if the parameter is null. + /// Thrown if the parameter is null. public DeviceUnavailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool expired) { if (discoveredDevice == null) throw new ArgumentNullException(nameof(discoveredDevice)); @@ -47,7 +47,7 @@ namespace Rssdp } /// - /// A reference to a instance containing the discovery details of the removed device. + /// A reference to a instance containing the discovery details of the removed device. /// public DiscoveredSsdpDevice DiscoveredDevice { diff --git a/RSSDP/DiscoveredSsdpDevice.cs b/RSSDP/DiscoveredSsdpDevice.cs index b643e3f08..f42e7c674 100644 --- a/RSSDP/DiscoveredSsdpDevice.cs +++ b/RSSDP/DiscoveredSsdpDevice.cs @@ -11,7 +11,7 @@ namespace Rssdp /// Represents a discovered device, containing basic information about the device and the location of it's full device description document. Also provides convenience methods for retrieving the device description document. /// /// - /// + /// public sealed class DiscoveredSsdpDevice { diff --git a/RSSDP/DisposableManagedObjectBase.cs b/RSSDP/DisposableManagedObjectBase.cs index 9933194bc..0f656fb46 100644 --- a/RSSDP/DisposableManagedObjectBase.cs +++ b/RSSDP/DisposableManagedObjectBase.cs @@ -20,10 +20,10 @@ namespace Rssdp.Infrastructure protected abstract void Dispose(bool disposing); /// - /// Throws and if the property is true. + /// Throws and if the property is true. /// /// - /// Thrown if the property is true. + /// Thrown if the property is true. /// protected virtual void ThrowIfDisposed() { diff --git a/RSSDP/HttpParserBase.cs b/RSSDP/HttpParserBase.cs index db496fe6f..18712470d 100644 --- a/RSSDP/HttpParserBase.cs +++ b/RSSDP/HttpParserBase.cs @@ -26,19 +26,19 @@ namespace Rssdp.Infrastructure private static byte[] EmptyByteArray = new byte[]{}; /// - /// Parses the provided into either a or object. + /// Parses the provided into either a or object. /// /// A string containing the HTTP message to parse. - /// Either a or object containing the parsed data. + /// Either a or object containing the parsed data. public abstract T Parse(string data); /// - /// Parses a string containing either an HTTP request or response into a or object. + /// Parses a string containing either an HTTP request or response into a or object. /// - /// A or object representing the parsed message. + /// A or object representing the parsed message. /// A reference to the collection for the object. /// A string containing the data to be parsed. - /// An object containing the content of the parsed message. + /// An object containing the content of the parsed message. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Honestly, it's fine. MemoryStream doesn't mind.")] protected virtual void Parse(T message, System.Net.Http.Headers.HttpHeaders headers, string data) { @@ -61,7 +61,7 @@ namespace Rssdp.Infrastructure /// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the . /// /// The first line of the HTTP message to be parsed. - /// Either a or to assign the parsed values to. + /// Either a or to assign the parsed values to. protected abstract void ParseStatusLine(string data, T message); /// diff --git a/RSSDP/HttpRequestParser.cs b/RSSDP/HttpRequestParser.cs index 1af7f0d51..d4505b8ad 100644 --- a/RSSDP/HttpRequestParser.cs +++ b/RSSDP/HttpRequestParser.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace Rssdp.Infrastructure { /// - /// Parses a string into a or throws an exception. + /// Parses a string into a or throws an exception. /// public sealed class HttpRequestParser : HttpParserBase { @@ -26,17 +26,17 @@ namespace Rssdp.Infrastructure #region Public Methods /// - /// Parses the specified data into a instance. + /// Parses the specified data into a instance. /// /// A string containing the data to parse. - /// A instance containing the parsed data. - public override System.Net.Http.HttpRequestMessage Parse(string data) + /// A instance containing the parsed data. + public override HttpRequestMessage Parse(string data) { - System.Net.Http.HttpRequestMessage retVal = null; + HttpRequestMessage retVal = null; try { - retVal = new System.Net.Http.HttpRequestMessage(); + retVal = new HttpRequestMessage(); Parse(retVal, retVal.Headers, data); @@ -57,7 +57,7 @@ namespace Rssdp.Infrastructure /// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the . /// /// The first line of the HTTP message to be parsed. - /// Either a or to assign the parsed values to. + /// Either a or to assign the parsed values to. protected override void ParseStatusLine(string data, HttpRequestMessage message) { if (data == null) throw new ArgumentNullException(nameof(data)); diff --git a/RSSDP/HttpResponseParser.cs b/RSSDP/HttpResponseParser.cs index d864a8bb7..a77c898ff 100644 --- a/RSSDP/HttpResponseParser.cs +++ b/RSSDP/HttpResponseParser.cs @@ -9,9 +9,9 @@ using System.Threading.Tasks; namespace Rssdp.Infrastructure { /// - /// Parses a string into a or throws an exception. + /// Parses a string into a or throws an exception. /// - public sealed class HttpResponseParser : HttpParserBase + public sealed class HttpResponseParser : HttpParserBase { #region Fields & Constants @@ -26,16 +26,16 @@ namespace Rssdp.Infrastructure #region Public Methods /// - /// Parses the specified data into a instance. + /// Parses the specified data into a instance. /// /// A string containing the data to parse. - /// A instance containing the parsed data. + /// A instance containing the parsed data. public override HttpResponseMessage Parse(string data) { - System.Net.Http.HttpResponseMessage retVal = null; + HttpResponseMessage retVal = null; try { - retVal = new System.Net.Http.HttpResponseMessage(); + retVal = new HttpResponseMessage(); Parse(retVal, retVal.Headers, data); @@ -68,7 +68,7 @@ namespace Rssdp.Infrastructure /// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the . /// /// The first line of the HTTP message to be parsed. - /// Either a or to assign the parsed values to. + /// Either a or to assign the parsed values to. protected override void ParseStatusLine(string data, HttpResponseMessage message) { if (data == null) throw new ArgumentNullException(nameof(data)); diff --git a/RSSDP/ISsdpDeviceLocator.cs b/RSSDP/ISsdpDeviceLocator.cs index 2351f5d62..8f0d39e75 100644 --- a/RSSDP/ISsdpDeviceLocator.cs +++ b/RSSDP/ISsdpDeviceLocator.cs @@ -128,7 +128,7 @@ namespace Rssdp.Infrastructure /// /// Does nothing if this instance is not already listening for notifications. /// - /// Throw if the property is true. + /// Throw if the property is true. /// /// /// diff --git a/RSSDP/ISsdpDevicePublisher.cs b/RSSDP/ISsdpDevicePublisher.cs index da2607fc4..7e914c109 100644 --- a/RSSDP/ISsdpDevicePublisher.cs +++ b/RSSDP/ISsdpDevicePublisher.cs @@ -17,14 +17,14 @@ namespace Rssdp.Infrastructure /// Adds a device (and it's children) to the list of devices being published by this server, making them discoverable to SSDP clients. /// /// The instance to add. - /// An awaitable . + /// An awaitable . void AddDevice(SsdpRootDevice device); /// /// Removes a device (and it's children) from the list of devices being published by this server, making them undiscoverable. /// /// The instance to add. - /// An awaitable . + /// An awaitable . Task RemoveDevice(SsdpRootDevice device); /// diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs index 8fb33924f..abd0dbdad 100644 --- a/RSSDP/SsdpCommunicationsServer.cs +++ b/RSSDP/SsdpCommunicationsServer.cs @@ -73,7 +73,7 @@ namespace Rssdp.Infrastructure /// /// Minimum constructor. /// - /// The argument is null. + /// The argument is null. public SsdpCommunicationsServer(ISocketFactory socketFactory, INetworkManager networkManager, ILogger logger, bool enableMultiSocketBinding) : this(socketFactory, 0, SsdpConstants.SsdpDefaultMulticastTimeToLive, networkManager, logger, enableMultiSocketBinding) { @@ -82,8 +82,8 @@ namespace Rssdp.Infrastructure /// /// Full constructor. /// - /// The argument is null. - /// The argument is less than or equal to zero. + /// The argument is null. + /// The argument is less than or equal to zero. public SsdpCommunicationsServer(ISocketFactory socketFactory, int localPort, int multicastTimeToLive, INetworkManager networkManager, ILogger logger, bool enableMultiSocketBinding) { if (socketFactory == null) throw new ArgumentNullException(nameof(socketFactory)); @@ -111,7 +111,7 @@ namespace Rssdp.Infrastructure /// /// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications. /// - /// Thrown if the property is true (because has been called previously). + /// Thrown if the property is true (because has been called previously). public void BeginListeningForBroadcasts() { ThrowIfDisposed(); @@ -138,7 +138,7 @@ namespace Rssdp.Infrastructure /// /// Causes the server to stop listening for multicast messages, being SSDP search requests and notifications. /// - /// Thrown if the property is true (because has been called previously). + /// Thrown if the property is true (because has been called previously). public void StopListeningForBroadcasts() { lock (_BroadcastListenSocketSynchroniser) @@ -269,7 +269,7 @@ namespace Rssdp.Infrastructure /// /// Stops listening for search responses on the local, unicast socket. /// - /// Thrown if the property is true (because has been called previously). + /// Thrown if the property is true (because has been called previously). public void StopListeningForResponses() { lock (_SendSocketSynchroniser) diff --git a/RSSDP/SsdpDevice.cs b/RSSDP/SsdpDevice.cs index 8dc1805c5..b4c4a88fd 100644 --- a/RSSDP/SsdpDevice.cs +++ b/RSSDP/SsdpDevice.cs @@ -276,8 +276,8 @@ namespace Rssdp /// If the device is already a member of the collection, this method does nothing. /// Also sets the property of the added device and all descendant devices to the relevant instance. /// - /// Thrown if the argument is null. - /// Thrown if the is already associated with a different instance than used in this tree. Can occur if you try to add the same device instance to more than one tree. Also thrown if you try to add a device to itself. + /// Thrown if the argument is null. + /// Thrown if the is already associated with a different instance than used in this tree. Can occur if you try to add the same device instance to more than one tree. Also thrown if you try to add a device to itself. /// public void AddDevice(SsdpEmbeddedDevice device) { @@ -305,7 +305,7 @@ namespace Rssdp /// If the device is not a member of the collection, this method does nothing. /// Also sets the property to null for the removed device and all descendant devices. /// - /// Thrown if the argument is null. + /// Thrown if the argument is null. /// public void RemoveDevice(SsdpEmbeddedDevice device) { diff --git a/RSSDP/SsdpDeviceLocator.cs b/RSSDP/SsdpDeviceLocator.cs index ca6093725..1348cce8d 100644 --- a/RSSDP/SsdpDeviceLocator.cs +++ b/RSSDP/SsdpDeviceLocator.cs @@ -185,7 +185,7 @@ namespace Rssdp.Infrastructure /// /// /// - /// Throw if the ty is true. + /// Throw if the ty is true. public void StartListeningForNotifications() { ThrowIfDisposed(); @@ -204,7 +204,7 @@ namespace Rssdp.Infrastructure /// /// /// - /// Throw if the property is true. + /// Throw if the property is true. public void StopListeningForNotifications() { ThrowIfDisposed(); diff --git a/RSSDP/SsdpDevicePublisher.cs b/RSSDP/SsdpDevicePublisher.cs index 031b908dd..8a73e6a2d 100644 --- a/RSSDP/SsdpDevicePublisher.cs +++ b/RSSDP/SsdpDevicePublisher.cs @@ -76,8 +76,8 @@ namespace Rssdp.Infrastructure /// This method ignores duplicate device adds (if the same device instance is added multiple times, the second and subsequent add calls do nothing). /// /// The instance to add. - /// Thrown if the argument is null. - /// Thrown if the contains property values that are not acceptable to the UPnP 1.0 specification. + /// Thrown if the argument is null. + /// Thrown if the contains property values that are not acceptable to the UPnP 1.0 specification. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "t", Justification = "Capture task to local variable supresses compiler warning, but task is not really needed.")] public void AddDevice(SsdpRootDevice device) { @@ -85,7 +85,7 @@ namespace Rssdp.Infrastructure ThrowIfDisposed(); - TimeSpan minCacheTime = TimeSpan.Zero; + var minCacheTime = TimeSpan.Zero; bool wasAdded = false; lock (_Devices) { @@ -113,13 +113,13 @@ namespace Rssdp.Infrastructure /// This method does nothing if the device was not found in the collection. /// /// The instance to add. - /// Thrown if the argument is null. + /// Thrown if the argument is null. public async Task RemoveDevice(SsdpRootDevice device) { if (device == null) throw new ArgumentNullException(nameof(device)); bool wasRemoved = false; - TimeSpan minCacheTime = TimeSpan.Zero; + var minCacheTime = TimeSpan.Zero; lock (_Devices) { if (_Devices.Contains(device)) diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index 6b7564828..1251d19c0 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -161,7 +161,7 @@ namespace SocketHttpListener internal static bool Contains(this IEnumerable source, Func condition) { - foreach (T elm in source) + foreach (var elm in source) if (condition(elm)) return true; diff --git a/SocketHttpListener/MessageEventArgs.cs b/SocketHttpListener/MessageEventArgs.cs index d9bccbf3f..8e2151cb7 100644 --- a/SocketHttpListener/MessageEventArgs.cs +++ b/SocketHttpListener/MessageEventArgs.cs @@ -9,8 +9,8 @@ namespace SocketHttpListener /// /// A event occurs when the receives /// a text or binary data frame. - /// If you want to get the received data, you access the or - /// property. + /// If you want to get the received data, you access the or + /// property. /// public class MessageEventArgs : EventArgs { diff --git a/SocketHttpListener/Net/ChunkStream.cs b/SocketHttpListener/Net/ChunkStream.cs index 4bf3a6dea..3836947d4 100644 --- a/SocketHttpListener/Net/ChunkStream.cs +++ b/SocketHttpListener/Net/ChunkStream.cs @@ -108,7 +108,7 @@ namespace SocketHttpListener.Net var chunksForRemoving = new List(count); for (int i = 0; i < count; i++) { - Chunk chunk = _chunks[i]; + var chunk = _chunks[i]; if (chunk.Offset == chunk.Bytes.Length) { @@ -189,7 +189,7 @@ namespace SocketHttpListener.Net int count = _chunks.Count; for (int i = 0; i < count; i++) { - Chunk ch = _chunks[i]; + var ch = _chunks[i]; if (ch == null || ch.Bytes == null) continue; if (ch.Bytes.Length > 0 && ch.Offset < ch.Bytes.Length) @@ -368,7 +368,7 @@ namespace SocketHttpListener.Net return State.Trailer; } - StringReader reader = new StringReader(_saved.ToString()); + var reader = new StringReader(_saved.ToString()); string line; while ((line = reader.ReadLine()) != null && line != "") _headers.Add(line); @@ -378,7 +378,7 @@ namespace SocketHttpListener.Net private static void ThrowProtocolViolation(string message) { - WebException we = new WebException(message, null, WebExceptionStatus.ServerProtocolViolation, null); + var we = new WebException(message, null, WebExceptionStatus.ServerProtocolViolation, null); throw we; } } diff --git a/SocketHttpListener/Net/ChunkedInputStream.cs b/SocketHttpListener/Net/ChunkedInputStream.cs index cdf7ac649..8d59a7907 100644 --- a/SocketHttpListener/Net/ChunkedInputStream.cs +++ b/SocketHttpListener/Net/ChunkedInputStream.cs @@ -61,7 +61,7 @@ namespace SocketHttpListener.Net : base(stream, buffer, offset, length) { _context = context; - WebHeaderCollection coll = (WebHeaderCollection)context.Request.Headers; + var coll = (WebHeaderCollection)context.Request.Headers; _decoder = new ChunkStream(coll); } @@ -73,13 +73,13 @@ namespace SocketHttpListener.Net protected override int ReadCore(byte[] buffer, int offset, int count) { - IAsyncResult ares = BeginReadCore(buffer, offset, count, null, null); + var ares = BeginReadCore(buffer, offset, count, null, null); return EndRead(ares); } protected override IAsyncResult BeginReadCore(byte[] buffer, int offset, int size, AsyncCallback cback, object state) { - HttpStreamAsyncResult ares = new HttpStreamAsyncResult(this); + var ares = new HttpStreamAsyncResult(this); ares._callback = cback; ares._state = state; if (_no_more_data || size == 0 || _closed) @@ -107,7 +107,7 @@ namespace SocketHttpListener.Net ares._buffer = new byte[8192]; ares._offset = 0; ares._count = 8192; - ReadBufferState rb = new ReadBufferState(buffer, offset, size, ares); + var rb = new ReadBufferState(buffer, offset, size, ares); rb.InitialCount += nread; base.BeginReadCore(ares._buffer, ares._offset, ares._count, OnRead, rb); return ares; @@ -115,8 +115,8 @@ namespace SocketHttpListener.Net private void OnRead(IAsyncResult base_ares) { - ReadBufferState rb = (ReadBufferState)base_ares.AsyncState; - HttpStreamAsyncResult ares = rb.Ares; + var rb = (ReadBufferState)base_ares.AsyncState; + var ares = rb.Ares; try { int nread = base.EndRead(base_ares); @@ -155,7 +155,7 @@ namespace SocketHttpListener.Net if (asyncResult == null) throw new ArgumentNullException(nameof(asyncResult)); - HttpStreamAsyncResult ares = asyncResult as HttpStreamAsyncResult; + var ares = asyncResult as HttpStreamAsyncResult; if (ares == null || !ReferenceEquals(this, ares._parent)) { throw new ArgumentException("Invalid async result"); diff --git a/SocketHttpListener/Net/HttpConnection.cs b/SocketHttpListener/Net/HttpConnection.cs index f6db5f0b2..e87503118 100644 --- a/SocketHttpListener/Net/HttpConnection.cs +++ b/SocketHttpListener/Net/HttpConnection.cs @@ -212,7 +212,7 @@ namespace SocketHttpListener.Net private static void OnRead(IAsyncResult ares) { - HttpConnection cnc = (HttpConnection)ares.AsyncState; + var cnc = (HttpConnection)ares.AsyncState; cnc.OnReadInternal(ares); } @@ -269,7 +269,7 @@ namespace SocketHttpListener.Net Close(true); return; } - HttpListener listener = _epl.Listener; + var listener = _epl.Listener; if (_lastListener != listener) { RemoveConnection(); @@ -417,7 +417,7 @@ namespace SocketHttpListener.Net { try { - HttpListenerResponse response = _context.Response; + var response = _context.Response; response.StatusCode = status; response.ContentType = "text/html"; string description = HttpStatusDescription.Get(status); @@ -509,7 +509,7 @@ namespace SocketHttpListener.Net return; } - Socket s = _socket; + var s = _socket; _socket = null; try { diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs index 0f1ce696f..d002c13b2 100644 --- a/SocketHttpListener/Net/HttpEndPointListener.cs +++ b/SocketHttpListener/Net/HttpEndPointListener.cs @@ -160,7 +160,7 @@ namespace SocketHttpListener.Net } catch (Exception ex) { - HttpEndPointListener epl = (HttpEndPointListener)acceptEventArg.UserToken; + var epl = (HttpEndPointListener)acceptEventArg.UserToken; epl._logger.LogError(ex, "Error in socket.AcceptAsync"); } @@ -176,7 +176,7 @@ namespace SocketHttpListener.Net private static async void ProcessAccept(SocketAsyncEventArgs args) { - HttpEndPointListener epl = (HttpEndPointListener)args.UserToken; + var epl = (HttpEndPointListener)args.UserToken; if (epl._closed) { @@ -214,7 +214,7 @@ namespace SocketHttpListener.Net var localEndPointString = accepted.LocalEndPoint == null ? string.Empty : accepted.LocalEndPoint.ToString(); //_logger.LogInformation("HttpEndPointListener Accepting connection from {0} to {1} secure connection requested: {2}", remoteEndPointString, localEndPointString, _secure); - HttpConnection conn = new HttpConnection(epl._logger, accepted, epl, epl._secure, epl._cert, epl._cryptoProvider, epl._streamHelper, epl._textEncoding, epl._fileSystem, epl._environment); + var conn = new HttpConnection(epl._logger, accepted, epl, epl._secure, epl._cert, epl._cryptoProvider, epl._streamHelper, epl._textEncoding, epl._fileSystem, epl._environment); await conn.Init().ConfigureAwait(false); @@ -276,9 +276,9 @@ namespace SocketHttpListener.Net public bool BindContext(HttpListenerContext context) { - HttpListenerRequest req = context.Request; + var req = context.Request; ListenerPrefix prefix; - HttpListener listener = SearchListener(req.Url, out prefix); + var listener = SearchListener(req.Url, out prefix); if (listener == null) return false; @@ -310,8 +310,8 @@ namespace SocketHttpListener.Net if (host != null && host != "") { - Dictionary localPrefixes = _prefixes; - foreach (ListenerPrefix p in localPrefixes.Keys) + var localPrefixes = _prefixes; + foreach (var p in localPrefixes.Keys) { string ppath = p.Path; if (ppath.Length < bestLength) @@ -331,7 +331,7 @@ namespace SocketHttpListener.Net return bestMatch; } - List list = _unhandledPrefixes; + var list = _unhandledPrefixes; bestMatch = MatchFromList(host, path, list, out prefix); if (path != pathSlash && bestMatch == null) @@ -361,7 +361,7 @@ namespace SocketHttpListener.Net HttpListener bestMatch = null; int bestLength = -1; - foreach (ListenerPrefix p in list) + foreach (var p in list) { string ppath = p.Path; if (ppath.Length < bestLength) @@ -383,7 +383,7 @@ namespace SocketHttpListener.Net if (list == null) return; - foreach (ListenerPrefix p in list) + foreach (var p in list) { if (p.Path == prefix.Path) throw new Exception("net_listener_already"); @@ -399,7 +399,7 @@ namespace SocketHttpListener.Net int c = list.Count; for (int i = 0; i < c; i++) { - ListenerPrefix p = list[i]; + var p = list[i]; if (p.Path == prefix.Path) { list.RemoveAt(i); @@ -414,7 +414,7 @@ namespace SocketHttpListener.Net if (_prefixes.Count > 0) return; - List list = _unhandledPrefixes; + var list = _unhandledPrefixes; if (list != null && list.Count > 0) return; @@ -434,7 +434,7 @@ namespace SocketHttpListener.Net // Clone the list because RemoveConnection can be called from Close var connections = new List(_unregisteredConnections.Keys); - foreach (HttpConnection c in connections) + foreach (var c in connections) c.Close(true); _unregisteredConnections.Clear(); } diff --git a/SocketHttpListener/Net/HttpEndPointManager.cs b/SocketHttpListener/Net/HttpEndPointManager.cs index 787730ed4..98986333b 100644 --- a/SocketHttpListener/Net/HttpEndPointManager.cs +++ b/SocketHttpListener/Net/HttpEndPointManager.cs @@ -17,7 +17,7 @@ namespace SocketHttpListener.Net public static void AddListener(ILogger logger, HttpListener listener) { - List added = new List(); + var added = new List(); try { lock ((s_ipEndPoints as ICollection).SyncRoot) @@ -64,7 +64,7 @@ namespace SocketHttpListener.Net } } - ListenerPrefix lp = new ListenerPrefix(p); + var lp = new ListenerPrefix(p); if (lp.Host != "*" && lp.Host != "+" && Uri.CheckHostName(lp.Host) == UriHostNameType.Unknown) throw new HttpListenerException((int)HttpStatusCode.BadRequest, "net_listener_host"); @@ -75,7 +75,7 @@ namespace SocketHttpListener.Net throw new HttpListenerException((int)HttpStatusCode.BadRequest, "net_invalid_path"); // listens on all the interfaces if host name cannot be parsed by IPAddress. - HttpEndPointListener epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); + var epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); epl.AddPrefix(lp, listener); } @@ -179,14 +179,14 @@ namespace SocketHttpListener.Net private static void RemovePrefixInternal(ILogger logger, string prefix, HttpListener listener) { - ListenerPrefix lp = new ListenerPrefix(prefix); + var lp = new ListenerPrefix(prefix); if (lp.Path.IndexOf('%') != -1) return; if (lp.Path.IndexOf("//", StringComparison.Ordinal) != -1) return; - HttpEndPointListener epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); + var epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); epl.RemovePrefix(lp, listener); } } diff --git a/SocketHttpListener/Net/HttpListenerContext.Managed.cs b/SocketHttpListener/Net/HttpListenerContext.Managed.cs index a6622c479..4cdb6882e 100644 --- a/SocketHttpListener/Net/HttpListenerContext.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerContext.Managed.cs @@ -44,7 +44,7 @@ namespace SocketHttpListener.Net } internal IPrincipal ParseBasicAuthentication(string authData) => - TryParseBasicAuth(authData, out HttpStatusCode errorCode, out string username, out string password) ? + TryParseBasicAuth(authData, out var errorCode, out string username, out string password) ? new GenericPrincipal(new HttpListenerBasicIdentity(username, password), Array.Empty()) : null; diff --git a/SocketHttpListener/Net/HttpListenerRequest.Managed.cs b/SocketHttpListener/Net/HttpListenerRequest.Managed.cs index 3f9e32f08..41d075045 100644 --- a/SocketHttpListener/Net/HttpListenerRequest.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerRequest.Managed.cs @@ -180,7 +180,7 @@ namespace SocketHttpListener.Net if (string.Compare(Headers[HttpKnownHeaderNames.Expect], "100-continue", StringComparison.OrdinalIgnoreCase) == 0) { - HttpResponseStream output = _context.Connection.GetResponseStream(); + var output = _context.Connection.GetResponseStream(); output.InternalWrite(s_100continue, 0, s_100continue.Length); } } @@ -256,7 +256,7 @@ namespace SocketHttpListener.Net { try { - IAsyncResult ares = InputStream.BeginRead(bytes, 0, length, null, null); + var ares = InputStream.BeginRead(bytes, 0, length, null, null); if (!ares.IsCompleted && !ares.AsyncWaitHandle.WaitOne(1000)) return false; if (InputStream.EndRead(ares) <= 0) diff --git a/SocketHttpListener/Net/HttpListenerRequest.cs b/SocketHttpListener/Net/HttpListenerRequest.cs index 2e8396f6f..1c832367e 100644 --- a/SocketHttpListener/Net/HttpListenerRequest.cs +++ b/SocketHttpListener/Net/HttpListenerRequest.cs @@ -23,7 +23,7 @@ namespace SocketHttpListener.Net private static CookieCollection ParseCookies(Uri uri, string setCookieHeader) { - CookieCollection cookies = new CookieCollection(); + var cookies = new CookieCollection(); return cookies; } @@ -171,7 +171,7 @@ namespace SocketHttpListener.Net { get { - QueryParamCollection queryString = new QueryParamCollection(); + var queryString = new QueryParamCollection(); Helpers.FillFromString(queryString, Url.Query, true, ContentEncoding); return queryString; } @@ -197,7 +197,7 @@ namespace SocketHttpListener.Net return null; } - bool success = Uri.TryCreate(referrer, UriKind.RelativeOrAbsolute, out Uri urlReferrer); + bool success = Uri.TryCreate(referrer, UriKind.RelativeOrAbsolute, out var urlReferrer); return success ? urlReferrer : null; } } @@ -296,7 +296,7 @@ namespace SocketHttpListener.Net // collect comma-separated values into list - List values = new List(); + var values = new List(); int i = 0; while (i < l) @@ -341,7 +341,7 @@ namespace SocketHttpListener.Net private static string UrlDecodeStringFromStringInternal(string s, Encoding e) { int count = s.Length; - UrlDecoder helper = new UrlDecoder(count, e); + var helper = new UrlDecoder(count, e); // go through the string's chars collapsing %XX and %uXXXX and // appending each char as char, with exception of %XX constructs diff --git a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs index f1a0af0bf..310c71a0d 100644 --- a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs +++ b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs @@ -54,7 +54,7 @@ namespace SocketHttpListener.Net public static Uri GetRequestUri(string rawUri, string cookedUriScheme, string cookedUriHost, string cookedUriPath, string cookedUriQuery) { - HttpListenerRequestUriBuilder builder = new HttpListenerRequestUriBuilder(rawUri, + var builder = new HttpListenerRequestUriBuilder(rawUri, cookedUriScheme, cookedUriHost, cookedUriPath, cookedUriQuery); return builder.Build(); @@ -94,10 +94,10 @@ namespace SocketHttpListener.Net // Try to check the raw path using first the primary encoding (according to http.sys settings); // if it fails try the secondary encoding. - ParsingResult result = BuildRequestUriUsingRawPath(GetEncoding(EncodingType.Primary)); + var result = BuildRequestUriUsingRawPath(GetEncoding(EncodingType.Primary)); if (result == ParsingResult.EncodingError) { - Encoding secondaryEncoding = GetEncoding(EncodingType.Secondary); + var secondaryEncoding = GetEncoding(EncodingType.Secondary); result = BuildRequestUriUsingRawPath(secondaryEncoding); } isValid = (result == ParsingResult.Success) ? true : false; @@ -136,7 +136,7 @@ namespace SocketHttpListener.Net _requestUriString.Append(Uri.SchemeDelimiter); _requestUriString.Append(_cookedUriHost); - ParsingResult result = ParseRawPath(encoding); + var result = ParseRawPath(encoding); if (result == ParsingResult.Success) { _requestUriString.Append(_cookedUriQuery); @@ -327,7 +327,7 @@ namespace SocketHttpListener.Net private static string GetOctetsAsString(IEnumerable octets) { - StringBuilder octetString = new StringBuilder(); + var octetString = new StringBuilder(); bool first = true; foreach (byte octet in octets) diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs index 198cdcf76..9f9b8384d 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs @@ -263,8 +263,8 @@ namespace SocketHttpListener.Net ComputeCookies(); } - Encoding encoding = _textEncoding.GetDefaultEncoding(); - StreamWriter writer = new StreamWriter(ms, encoding, 256); + var encoding = _textEncoding.GetDefaultEncoding(); + var writer = new StreamWriter(ms, encoding, 256); writer.Write("HTTP/1.1 {0} ", _statusCode); // "1.1" matches Windows implementation, which ignores the response version writer.Flush(); byte[] statusDescriptionBytes = WebHeaderEncoding.GetBytes(StatusDescription); diff --git a/SocketHttpListener/Net/HttpRequestStream.Managed.cs b/SocketHttpListener/Net/HttpRequestStream.Managed.cs index 73a673531..42fc4d97c 100644 --- a/SocketHttpListener/Net/HttpRequestStream.Managed.cs +++ b/SocketHttpListener/Net/HttpRequestStream.Managed.cs @@ -124,7 +124,7 @@ namespace SocketHttpListener.Net { if (size == 0 || _closed) { - HttpStreamAsyncResult ares = new HttpStreamAsyncResult(this); + var ares = new HttpStreamAsyncResult(this); ares._callback = cback; ares._state = state; ares.Complete(); @@ -134,7 +134,7 @@ namespace SocketHttpListener.Net int nread = FillFromBuffer(buffer, offset, size); if (nread > 0 || nread == -1) { - HttpStreamAsyncResult ares = new HttpStreamAsyncResult(this); + var ares = new HttpStreamAsyncResult(this); ares._buffer = buffer; ares._offset = offset; ares._count = size; diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs index b4c223418..cda4fe8bc 100644 --- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs +++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs @@ -70,7 +70,7 @@ namespace SocketHttpListener.Net private void DisposeCore() { byte[] bytes = null; - MemoryStream ms = GetHeaders(true); + var ms = GetHeaders(true); bool chunked = _response.SendChunked; if (_stream.CanWrite) { @@ -110,7 +110,7 @@ namespace SocketHttpListener.Net if (_stream.CanWrite) { - MemoryStream ms = GetHeaders(closing: false, isWebSocketHandshake: true); + var ms = GetHeaders(closing: false, isWebSocketHandshake: true); bool chunked = _response.SendChunked; long start = ms.Position; @@ -146,7 +146,7 @@ namespace SocketHttpListener.Net return null; } - MemoryStream ms = new MemoryStream(); + var ms = new MemoryStream(); _response.SendHeaders(closing, ms, isWebSocketHandshake); return ms; } @@ -190,7 +190,7 @@ namespace SocketHttpListener.Net return; byte[] bytes = null; - MemoryStream ms = GetHeaders(false); + var ms = GetHeaders(false); bool chunked = _response.SendChunked; if (ms != null) { @@ -226,7 +226,7 @@ namespace SocketHttpListener.Net { if (_closed) { - HttpStreamAsyncResult ares = new HttpStreamAsyncResult(this); + var ares = new HttpStreamAsyncResult(this); ares._callback = cback; ares._state = state; ares.Complete(); @@ -234,7 +234,7 @@ namespace SocketHttpListener.Net } byte[] bytes = null; - MemoryStream ms = GetHeaders(false); + var ms = GetHeaders(false); bool chunked = _response.SendChunked; if (ms != null) { diff --git a/SocketHttpListener/Net/ListenerPrefix.cs b/SocketHttpListener/Net/ListenerPrefix.cs index 3e78752fd..edfcb8904 100644 --- a/SocketHttpListener/Net/ListenerPrefix.cs +++ b/SocketHttpListener/Net/ListenerPrefix.cs @@ -40,7 +40,7 @@ namespace SocketHttpListener.Net // Equals and GetHashCode are required to detect duplicates in HttpListenerPrefixCollection. public override bool Equals(object o) { - ListenerPrefix other = o as ListenerPrefix; + var other = o as ListenerPrefix; if (other == null) return false; diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs index 8c3395df5..02d3cf61f 100644 --- a/SocketHttpListener/Net/WebHeaderCollection.cs +++ b/SocketHttpListener/Net/WebHeaderCollection.cs @@ -234,7 +234,7 @@ namespace SocketHttpListener.Net internal string ToStringMultiValue() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); int count = base.Count; for (int i = 0; i < count; i++) @@ -263,7 +263,7 @@ namespace SocketHttpListener.Net public override string ToString() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); int count = base.Count; for (int i = 0; i < count; i++) diff --git a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs index 79f87dfc9..f51f72dba 100644 --- a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs +++ b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs @@ -16,8 +16,8 @@ namespace SocketHttpListener.Net.WebSockets ValidateOptions(subProtocol, receiveBufferSize, MinSendBufferSize, keepAliveInterval); // get property will create a new response if one doesn't exist. - HttpListenerResponse response = context.Response; - HttpListenerRequest request = context.Request; + var response = context.Response; + var request = context.Request; ValidateWebSocketHeaders(context); string secWebSocketVersion = request.Headers[HttpKnownHeaderNames.SecWebSocketVersion]; @@ -50,15 +50,15 @@ namespace SocketHttpListener.Net.WebSockets response.StatusCode = (int)HttpStatusCode.SwitchingProtocols; // HTTP 101 response.StatusDescription = HttpStatusDescription.Get(HttpStatusCode.SwitchingProtocols); - HttpResponseStream responseStream = response.OutputStream as HttpResponseStream; + var responseStream = response.OutputStream as HttpResponseStream; // Send websocket handshake headers await responseStream.WriteWebSocketHandshakeHeadersAsync().ConfigureAwait(false); //WebSocket webSocket = WebSocket.CreateFromStream(context.Connection.ConnectedStream, isServer: true, subProtocol, keepAliveInterval); - WebSocket webSocket = new WebSocket(subProtocol); + var webSocket = new WebSocket(subProtocol); - HttpListenerWebSocketContext webSocketContext = new HttpListenerWebSocketContext( + var webSocketContext = new HttpListenerWebSocketContext( request.Url, request.Headers, request.Cookies, diff --git a/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs b/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs index 4667275c5..b346cc98e 100644 --- a/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs +++ b/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs @@ -19,7 +19,7 @@ namespace SocketHttpListener.Net.WebSockets string retVal; // SHA1 used only for hashing purposes, not for crypto. Check here for FIPS compat. - using (SHA1 sha1 = SHA1.Create()) + using (var sha1 = SHA1.Create()) { string acceptString = string.Concat(secWebSocketKey, HttpWebSocket.SecWebSocketKeyGuid); byte[] toHash = Encoding.UTF8.GetBytes(acceptString); diff --git a/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs b/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs index 0469e3b6c..3f61e55fc 100644 --- a/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs +++ b/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs @@ -20,7 +20,7 @@ namespace SocketHttpListener.Net.WebSockets if (validStates != null && validStates.Length > 0) { - foreach (WebSocketState validState in validStates) + foreach (var validState in validStates) { if (currentState == validState) { -- cgit v1.2.3 From e8674464373c3635243953cded42fcd2aa87d196 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 13 Jan 2019 21:46:33 +0100 Subject: ReSharper format: conform inline 'out' parameters. --- DvdLib/Ifo/Dvd.cs | 3 +- Emby.Dlna/ContentDirectory/ControlHandler.cs | 19 ++----- Emby.Dlna/DlnaManager.cs | 7 +-- Emby.Dlna/Eventing/EventManager.cs | 11 +--- Emby.Dlna/Main/DlnaEntryPoint.cs | 3 +- Emby.Dlna/PlayTo/Device.cs | 4 +- Emby.Dlna/PlayTo/PlayToController.cs | 43 ++++---------- Emby.Dlna/PlayTo/PlayToManager.cs | 9 +-- Emby.Drawing/ImageProcessor.cs | 3 +- Emby.Naming/Audio/AlbumParser.cs | 3 +- Emby.Naming/AudioBook/AudioBookFilePathParser.cs | 6 +- Emby.Naming/TV/EpisodePathParser.cs | 6 +- Emby.Naming/TV/SeasonPathParser.cs | 9 +-- Emby.Naming/Video/CleanDateTimeParser.cs | 3 +- Emby.Photos/PhotoProvider.cs | 4 +- .../Channels/ChannelManager.cs | 4 +- .../Data/SqliteExtensions.cs | 34 ++++------- .../Data/SqliteItemRepository.cs | 29 +++------- Emby.Server.Implementations/Devices/DeviceId.cs | 3 +- .../Devices/DeviceManager.cs | 3 +- Emby.Server.Implementations/Dto/DtoService.cs | 4 +- .../EntryPoints/ExternalPortForwarding.cs | 12 ++-- .../EntryPoints/LibraryChangedNotifier.cs | 3 +- .../EntryPoints/UserDataChangeNotifier.cs | 4 +- .../HttpClientManager/HttpClientManager.cs | 4 +- .../HttpServer/HttpListenerHost.cs | 12 ++-- .../HttpServer/HttpResultFactory.cs | 17 ++---- .../HttpServer/ResponseFilter.cs | 3 +- .../HttpServer/Security/AuthService.cs | 3 +- .../HttpServer/Security/AuthorizationContext.cs | 3 +- .../HttpServer/Security/SessionContext.cs | 3 +- Emby.Server.Implementations/IO/LibraryMonitor.cs | 11 +--- .../Library/LibraryManager.cs | 7 +-- .../Library/MediaSourceManager.cs | 7 +-- .../LiveTv/EmbyTV/EmbyTV.cs | 30 +++------- .../LiveTv/EmbyTV/TimerManager.cs | 3 +- .../LiveTv/LiveTvManager.cs | 6 +- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 3 +- .../TunerHosts/HdHomerun/HdHomerunManager.cs | 9 +-- .../LiveTv/TunerHosts/M3UTunerHost.cs | 3 +- .../LiveTv/TunerHosts/M3uParser.cs | 33 ++++------- .../Localization/LocalizationManager.cs | 16 ++---- .../Networking/IPNetwork/IPNetwork.cs | 39 +++++-------- .../Networking/NetworkManager.cs | 20 ++----- .../ScheduledTasks/TaskManager.cs | 3 +- .../Security/MBLicenseFile.cs | 9 +-- .../Serialization/XmlSerializer.cs | 3 +- .../Services/ServiceController.cs | 3 +- .../Services/ServiceExec.cs | 3 +- .../Services/ServiceHandler.cs | 9 +-- .../Services/ServicePath.cs | 6 +- .../Session/SessionManager.cs | 6 +- .../TextEncoding/NLangDetect/ProbVector.cs | 4 +- .../TextEncoding/NLangDetect/Utils/Messages.cs | 4 +- .../Updates/InstallationManager.cs | 4 +- Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs | 9 +-- Jellyfin.Server/SocketSharp/RequestMono.cs | 4 +- MediaBrowser.Api/ApiEntryPoint.cs | 3 +- MediaBrowser.Api/IHasItemFields.cs | 4 +- MediaBrowser.Api/Images/ImageService.cs | 3 +- MediaBrowser.Api/Playback/BaseStreamingService.cs | 9 +-- MediaBrowser.Api/Session/SessionsService.cs | 3 +- MediaBrowser.Common/Net/HttpRequestOptions.cs | 4 +- .../Entities/CollectionFolder.cs | 3 +- MediaBrowser.Controller/Entities/Folder.cs | 4 +- MediaBrowser.Controller/Entities/Year.cs | 8 +-- MediaBrowser.Controller/Library/TVUtils.cs | 4 +- .../MediaEncoding/EncodingHelper.cs | 4 +- .../MediaEncoding/EncodingJobInfo.cs | 15 ++--- .../MediaEncoding/EncodingJobOptions.cs | 3 +- MediaBrowser.Controller/MediaEncoding/JobLogger.cs | 14 ++--- .../Providers/DirectoryService.cs | 10 +--- .../Parsers/BaseItemXmlParser.cs | 33 ++++------- .../Parsers/GameXmlParser.cs | 4 +- .../Probing/FFProbeHelpers.cs | 12 +--- .../Probing/ProbeResultNormalizer.cs | 41 ++++---------- MediaBrowser.MediaEncoding/Subtitles/AssParser.cs | 3 +- MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs | 3 +- MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs | 3 +- MediaBrowser.Model/Configuration/LibraryOptions.cs | 3 +- MediaBrowser.Model/Dlna/ConditionProcessor.cs | 12 ++-- MediaBrowser.Model/Dlna/StreamBuilder.cs | 39 +++++-------- MediaBrowser.Model/Dlna/StreamInfo.cs | 18 ++---- MediaBrowser.Model/Drawing/ImageSize.cs | 4 +- .../Entities/ProviderIdsExtensions.cs | 3 +- MediaBrowser.Model/Net/MimeTypes.cs | 6 +- MediaBrowser.Providers/Manager/ProviderManager.cs | 6 +- .../Manager/SimplePriorityQueue.cs | 3 +- .../MediaInfo/FFProbeVideoInfo.cs | 4 +- .../Movies/FanartMovieImageProvider.cs | 3 +- .../Movies/GenericMovieDbInfo.cs | 7 +-- MediaBrowser.Providers/Movies/MovieDbProvider.cs | 4 +- MediaBrowser.Providers/Movies/MovieDbSearch.cs | 8 +-- MediaBrowser.Providers/Music/Extensions.cs | 6 +- .../Music/FanArtAlbumProvider.cs | 3 +- .../Music/FanArtArtistProvider.cs | 3 +- .../Music/MusicBrainzAlbumProvider.cs | 3 +- MediaBrowser.Providers/Omdb/OmdbItemProvider.cs | 6 +- MediaBrowser.Providers/Omdb/OmdbProvider.cs | 30 +++------- .../People/MovieDbPersonProvider.cs | 4 +- .../TV/FanArt/FanArtSeasonProvider.cs | 7 +-- .../TV/FanArt/FanartSeriesProvider.cs | 3 +- .../TV/MissingEpisodeProvider.cs | 11 +--- .../TV/Omdb/OmdbEpisodeProvider.cs | 3 +- .../TV/TheMovieDb/MovieDbEpisodeProvider.cs | 3 +- .../TV/TheMovieDb/MovieDbSeasonProvider.cs | 3 +- .../TV/TheMovieDb/MovieDbSeriesProvider.cs | 3 +- .../TV/TheTVDB/TvdbEpisodeImageProvider.cs | 8 +-- .../TV/TheTVDB/TvdbEpisodeProvider.cs | 42 ++++---------- .../TV/TheTVDB/TvdbPrescanTask.cs | 4 +- .../TV/TheTVDB/TvdbSeasonImageProvider.cs | 12 +--- .../TV/TheTVDB/TvdbSeriesImageProvider.cs | 12 +--- .../TV/TheTVDB/TvdbSeriesProvider.cs | 65 +++++++--------------- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 39 ++++--------- .../Parsers/EpisodeNfoParser.cs | 32 +++-------- .../Parsers/SeasonNfoParser.cs | 4 +- .../Parsers/SeriesNfoParser.cs | 3 +- SocketHttpListener/Ext.cs | 3 +- SocketHttpListener/Net/CookieHelper.cs | 3 +- SocketHttpListener/Net/HttpEndPointListener.cs | 3 +- SocketHttpListener/Net/HttpEndPointManager.cs | 3 +- .../Net/HttpListenerRequestUriBuilder.cs | 6 +- SocketHttpListener/Net/WebHeaderCollection.cs | 6 +- .../Net/WebSockets/HttpWebSocket.Managed.cs | 3 +- 124 files changed, 354 insertions(+), 820 deletions(-) (limited to 'SocketHttpListener/Ext.cs') diff --git a/DvdLib/Ifo/Dvd.cs b/DvdLib/Ifo/Dvd.cs index 71ba2d5e4..f784be83e 100644 --- a/DvdLib/Ifo/Dvd.cs +++ b/DvdLib/Ifo/Dvd.cs @@ -31,10 +31,9 @@ namespace DvdLib.Ifo foreach (var ifo in allIfos) { var num = ifo.Name.Split('_').ElementAtOrDefault(1); - ushort ifoNumber; var numbersRead = new List(); - if (!string.IsNullOrEmpty(num) && ushort.TryParse(num, out ifoNumber) && !numbersRead.Contains(ifoNumber)) + if (!string.IsNullOrEmpty(num) && ushort.TryParse(num, out var ifoNumber) && !numbersRead.Contains(ifoNumber)) { ReadVTS(ifoNumber, ifo.FullName); numbersRead.Add(ifoNumber); diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index 5a8fd4068..ed2114e6a 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -192,9 +192,7 @@ namespace Emby.Dlna.ContentDirectory public string GetValueOrDefault(IDictionary sparams, string key, string defaultValue) { - string val; - - if (sparams.TryGetValue(key, out val)) + if (sparams.TryGetValue(key, out var val)) { return val; } @@ -216,14 +214,12 @@ namespace Emby.Dlna.ContentDirectory int? requestedCount = null; int? start = 0; - int requestedVal; - if (sparams.ContainsKey("RequestedCount") && int.TryParse(sparams["RequestedCount"], out requestedVal) && requestedVal > 0) + if (sparams.ContainsKey("RequestedCount") && int.TryParse(sparams["RequestedCount"], out var requestedVal) && requestedVal > 0) { requestedCount = requestedVal; } - int startVal; - if (sparams.ContainsKey("StartingIndex") && int.TryParse(sparams["StartingIndex"], out startVal) && startVal > 0) + if (sparams.ContainsKey("StartingIndex") && int.TryParse(sparams["StartingIndex"], out var startVal) && startVal > 0) { start = startVal; } @@ -334,14 +330,12 @@ namespace Emby.Dlna.ContentDirectory int? requestedCount = null; int? start = 0; - int requestedVal; - if (sparams.ContainsKey("RequestedCount") && int.TryParse(sparams["RequestedCount"], out requestedVal) && requestedVal > 0) + if (sparams.ContainsKey("RequestedCount") && int.TryParse(sparams["RequestedCount"], out var requestedVal) && requestedVal > 0) { requestedCount = requestedVal; } - int startVal; - if (sparams.ContainsKey("StartingIndex") && int.TryParse(sparams["StartingIndex"], out startVal) && startVal > 0) + if (sparams.ContainsKey("StartingIndex") && int.TryParse(sparams["StartingIndex"], out var startVal) && startVal > 0) { start = startVal; } @@ -1293,7 +1287,6 @@ namespace Emby.Dlna.ContentDirectory private ServerItem ParseItemId(string id, User user) { - Guid itemId; StubType? stubType = null; // After using PlayTo, MediaMonkey sends a request to the server trying to get item info @@ -1319,7 +1312,7 @@ namespace Emby.Dlna.ContentDirectory } } - if (Guid.TryParse(id, out itemId)) + if (Guid.TryParse(id, out var itemId)) { var item = _libraryManager.GetItemById(itemId); diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs index 62b261908..45ba44870 100644 --- a/Emby.Dlna/DlnaManager.cs +++ b/Emby.Dlna/DlnaManager.cs @@ -239,9 +239,7 @@ namespace Emby.Dlna return false; } - string value; - - if (headers.TryGetValue(header.Name, out value)) + if (headers.TryGetValue(header.Name, out var value)) { switch (header.Match) { @@ -288,8 +286,7 @@ namespace Emby.Dlna { lock (_profiles) { - Tuple profileTuple; - if (_profiles.TryGetValue(path, out profileTuple)) + if (_profiles.TryGetValue(path, out var profileTuple)) { return profileTuple.Item2; } diff --git a/Emby.Dlna/Eventing/EventManager.cs b/Emby.Dlna/Eventing/EventManager.cs index a416ebb2b..c17f64a57 100644 --- a/Emby.Dlna/Eventing/EventManager.cs +++ b/Emby.Dlna/Eventing/EventManager.cs @@ -82,9 +82,7 @@ namespace Emby.Dlna.Eventing // Starts with SECOND- header = header.Split('-').Last(); - int val; - - if (int.TryParse(header, NumberStyles.Integer, _usCulture, out val)) + if (int.TryParse(header, NumberStyles.Integer, _usCulture, out var val)) { return val; } @@ -97,8 +95,7 @@ namespace Emby.Dlna.Eventing { _logger.LogDebug("Cancelling event subscription {0}", subscriptionId); - EventSubscription sub; - _subscriptions.TryRemove(subscriptionId, out sub); + _subscriptions.TryRemove(subscriptionId, out var sub); return new EventSubscriptionResponse { @@ -129,9 +126,7 @@ namespace Emby.Dlna.Eventing private EventSubscription GetSubscription(string id, bool throwOnMissing) { - EventSubscription e; - - if (!_subscriptions.TryGetValue(id, out e) && throwOnMissing) + if (!_subscriptions.TryGetValue(id, out var e) && throwOnMissing) { throw new ResourceNotFoundException("Event with Id " + id + " not found."); } diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs index e0b4f025a..1ab6014eb 100644 --- a/Emby.Dlna/Main/DlnaEntryPoint.cs +++ b/Emby.Dlna/Main/DlnaEntryPoint.cs @@ -308,8 +308,7 @@ namespace Emby.Dlna.Main private string CreateUuid(string text) { - Guid guid; - if (!Guid.TryParse(text, out guid)) + if (!Guid.TryParse(text, out var guid)) { guid = text.GetMD5(); } diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs index a85720b5f..68aa0a6a7 100644 --- a/Emby.Dlna/PlayTo/Device.cs +++ b/Emby.Dlna/PlayTo/Device.cs @@ -589,9 +589,7 @@ namespace Emby.Dlna.PlayTo if (transportStateValue != null) { - TRANSPORTSTATE state; - - if (Enum.TryParse(transportStateValue, true, out state)) + if (Enum.TryParse(transportStateValue, true, out TRANSPORTSTATE state)) { return state; } diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index 85a37d7f8..c615b9fbc 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -98,14 +98,11 @@ namespace Emby.Dlna.PlayTo { var info = e.Argument; - string nts; - info.Headers.TryGetValue("NTS", out nts); + info.Headers.TryGetValue("NTS", out var nts); - string usn; - if (!info.Headers.TryGetValue("USN", out usn)) usn = string.Empty; + if (!info.Headers.TryGetValue("USN", out var usn)) usn = string.Empty; - string nt; - if (!info.Headers.TryGetValue("NT", out nt)) nt = string.Empty; + if (!info.Headers.TryGetValue("NT", out var nt)) nt = string.Empty; if (usn.IndexOf(_device.Properties.UUID, StringComparison.OrdinalIgnoreCase) != -1 && !_disposed) @@ -623,9 +620,7 @@ namespace Emby.Dlna.PlayTo private Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken) { - GeneralCommandType commandType; - - if (Enum.TryParse(command.Name, true, out commandType)) + if (Enum.TryParse(command.Name, true, out GeneralCommandType commandType)) { switch (commandType) { @@ -641,13 +636,9 @@ namespace Emby.Dlna.PlayTo return _device.ToggleMute(cancellationToken); case GeneralCommandType.SetAudioStreamIndex: { - string arg; - - if (command.Arguments.TryGetValue("Index", out arg)) + if (command.Arguments.TryGetValue("Index", out var arg)) { - int val; - - if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out val)) + if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var val)) { return SetAudioStreamIndex(val); } @@ -659,13 +650,9 @@ namespace Emby.Dlna.PlayTo } case GeneralCommandType.SetSubtitleStreamIndex: { - string arg; - - if (command.Arguments.TryGetValue("Index", out arg)) + if (command.Arguments.TryGetValue("Index", out var arg)) { - int val; - - if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out val)) + if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var val)) { return SetSubtitleStreamIndex(val); } @@ -677,13 +664,9 @@ namespace Emby.Dlna.PlayTo } case GeneralCommandType.SetVolume: { - string arg; - - if (command.Arguments.TryGetValue("Volume", out arg)) + if (command.Arguments.TryGetValue("Volume", out var arg)) { - int volume; - - if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out volume)) + if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var volume)) { return _device.SetVolume(volume, cancellationToken); } @@ -878,8 +861,7 @@ namespace Emby.Dlna.PlayTo { var value = values.Get(name); - int result; - if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) + if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -891,8 +873,7 @@ namespace Emby.Dlna.PlayTo { var value = values.Get(name); - long result; - if (long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) + if (long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs index d8d289c59..12280d1bf 100644 --- a/Emby.Dlna/PlayTo/PlayToManager.cs +++ b/Emby.Dlna/PlayTo/PlayToManager.cs @@ -78,11 +78,9 @@ namespace Emby.Dlna.PlayTo var info = e.Argument; - string usn; - if (!info.Headers.TryGetValue("USN", out usn)) usn = string.Empty; + if (!info.Headers.TryGetValue("USN", out var usn)) usn = string.Empty; - string nt; - if (!info.Headers.TryGetValue("NT", out nt)) nt = string.Empty; + if (!info.Headers.TryGetValue("NT", out var nt)) nt = string.Empty; string location = info.Location.ToString(); @@ -155,8 +153,7 @@ namespace Emby.Dlna.PlayTo _logger.LogDebug("Attempting to create PlayToController from location {0}", location); _logger.LogDebug("Logging session activity from location {0}", location); - string uuid; - if (info.Headers.TryGetValue("USN", out uuid)) + if (info.Headers.TryGetValue("USN", out var uuid)) { uuid = GetUuid(uuid); } diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index a88c720a7..ac6c7e9db 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -846,8 +846,7 @@ namespace Emby.Drawing { lock (_locks) { - LockInfo info; - if (_locks.TryGetValue(key, out info)) + if (_locks.TryGetValue(key, out var info)) { info.Count++; } diff --git a/Emby.Naming/Audio/AlbumParser.cs b/Emby.Naming/Audio/AlbumParser.cs index 8cf8ec5e5..7d029a9f4 100644 --- a/Emby.Naming/Audio/AlbumParser.cs +++ b/Emby.Naming/Audio/AlbumParser.cs @@ -49,8 +49,7 @@ namespace Emby.Naming.Audio tmp = tmp.Trim().Split(' ').FirstOrDefault() ?? string.Empty; - int val; - if (int.TryParse(tmp, NumberStyles.Integer, CultureInfo.InvariantCulture, out val)) + if (int.TryParse(tmp, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val)) { result.IsMultiPart = true; break; diff --git a/Emby.Naming/AudioBook/AudioBookFilePathParser.cs b/Emby.Naming/AudioBook/AudioBookFilePathParser.cs index b386593e7..590979794 100644 --- a/Emby.Naming/AudioBook/AudioBookFilePathParser.cs +++ b/Emby.Naming/AudioBook/AudioBookFilePathParser.cs @@ -34,8 +34,7 @@ namespace Emby.Naming.AudioBook var value = match.Groups["chapter"]; if (value.Success) { - int intValue; - if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out intValue)) + if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue)) { result.ChapterNumber = intValue; } @@ -46,8 +45,7 @@ namespace Emby.Naming.AudioBook var value = match.Groups["part"]; if (value.Success) { - int intValue; - if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out intValue)) + if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue)) { result.ChapterNumber = intValue; } diff --git a/Emby.Naming/TV/EpisodePathParser.cs b/Emby.Naming/TV/EpisodePathParser.cs index 260cb505c..9485d697b 100644 --- a/Emby.Naming/TV/EpisodePathParser.cs +++ b/Emby.Naming/TV/EpisodePathParser.cs @@ -122,8 +122,7 @@ namespace Emby.Naming.TV } else if (expression.IsNamed) { - int num; - if (int.TryParse(match.Groups["seasonnumber"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(match.Groups["seasonnumber"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var num)) { result.SeasonNumber = num; } @@ -154,8 +153,7 @@ namespace Emby.Naming.TV } else { - int num; - if (int.TryParse(match.Groups[1].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(match.Groups[1].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var num)) { result.SeasonNumber = num; } diff --git a/Emby.Naming/TV/SeasonPathParser.cs b/Emby.Naming/TV/SeasonPathParser.cs index 002bbe19c..f1dcc50b8 100644 --- a/Emby.Naming/TV/SeasonPathParser.cs +++ b/Emby.Naming/TV/SeasonPathParser.cs @@ -72,8 +72,7 @@ namespace Emby.Naming.TV if (supportNumericSeasonFolders) { - int val; - if (int.TryParse(filename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val)) + if (int.TryParse(filename, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val)) { return new Tuple(val, true); } @@ -83,8 +82,7 @@ namespace Emby.Naming.TV { var testFilename = filename.Substring(1); - int val; - if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val)) + if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val)) { return new Tuple(val, true); } @@ -121,8 +119,7 @@ namespace Emby.Naming.TV part = part.Substring(1); - int value; - if (int.TryParse(part, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) + if (int.TryParse(part, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value)) { return value; } diff --git a/Emby.Naming/Video/CleanDateTimeParser.cs b/Emby.Naming/Video/CleanDateTimeParser.cs index 702e7ae6f..74807ef53 100644 --- a/Emby.Naming/Video/CleanDateTimeParser.cs +++ b/Emby.Naming/Video/CleanDateTimeParser.cs @@ -71,8 +71,7 @@ namespace Emby.Naming.Video if (match.Success && match.Groups.Count == 4) { - int year; - if (match.Groups[1].Success && match.Groups[2].Success && int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out year)) + if (match.Groups[1].Success && match.Groups[2].Success && int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year)) { name = match.Groups[1].Value; result.Year = year; diff --git a/Emby.Photos/PhotoProvider.cs b/Emby.Photos/PhotoProvider.cs index 99d0ed7ab..4fcd418f0 100644 --- a/Emby.Photos/PhotoProvider.cs +++ b/Emby.Photos/PhotoProvider.cs @@ -7,6 +7,7 @@ using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using Microsoft.Extensions.Logging; @@ -144,8 +145,7 @@ namespace Emby.Photos } else { - MediaBrowser.Model.Drawing.ImageOrientation orientation; - if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out orientation)) + if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out ImageOrientation orientation)) { item.Orientation = orientation; } diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index e9002abfb..3650900c3 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -387,9 +387,7 @@ namespace Emby.Server.Implementations.Channels private async Task> GetChannelItemMediaSourcesInternal(IRequiresMediaInfoCallback channel, string id, CancellationToken cancellationToken) { - Tuple> cachedInfo; - - if (_channelItemMediaInfo.TryGetValue(id, out cachedInfo)) + if (_channelItemMediaInfo.TryGetValue(id, out var cachedInfo)) { if ((DateTime.UtcNow - cachedInfo.Item1).TotalMinutes < 5) { diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs index edb73d2a1..d990e7149 100644 --- a/Emby.Server.Implementations/Data/SqliteExtensions.cs +++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs @@ -114,9 +114,7 @@ namespace Emby.Server.Implementations.Data { var dateText = result.ToString(); - DateTime dateTimeResult; - - if (DateTime.TryParseExact(dateText, _datetimeFormats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out dateTimeResult)) + if (DateTime.TryParseExact(dateText, _datetimeFormats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out var dateTimeResult)) { return dateTimeResult.ToUniversalTime(); } @@ -201,8 +199,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, double value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.Bind(value); } @@ -214,8 +211,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, string value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { if (value == null) { @@ -234,8 +230,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, bool value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.Bind(value); } @@ -247,8 +242,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, float value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.Bind(value); } @@ -260,8 +254,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, int value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.Bind(value); } @@ -273,8 +266,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, Guid value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.Bind(value.ToGuidBlob()); } @@ -286,8 +278,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, DateTime value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.Bind(value.ToDateTimeParamValue()); } @@ -299,8 +290,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, long value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.Bind(value); } @@ -312,8 +302,7 @@ namespace Emby.Server.Implementations.Data public static void TryBind(this IStatement statement, string name, byte[] value) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.Bind(value); } @@ -325,8 +314,7 @@ namespace Emby.Server.Implementations.Data public static void TryBindNull(this IStatement statement, string name) { - IBindParameter bindParam; - if (statement.BindParameters.TryGetValue(name, out bindParam)) + if (statement.BindParameters.TryGetValue(name, out var bindParam)) { bindParam.BindNull(); } diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 7e7271371..972c5c52d 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -1164,25 +1164,21 @@ namespace Emby.Server.Implementations.Data image.Path = RestorePath(parts[0]); - long ticks; - if (long.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out ticks)) + if (long.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out var ticks)) { image.DateModified = new DateTime(ticks, DateTimeKind.Utc); } - ImageType type; - if (Enum.TryParse(parts[2], true, out type)) + if (Enum.TryParse(parts[2], true, out ImageType type)) { image.Type = type; } if (parts.Length >= 5) { - int width; - int height; - if (int.TryParse(parts[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out width)) + if (int.TryParse(parts[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out var width)) { - if (int.TryParse(parts[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out height)) + if (int.TryParse(parts[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out var height)) { image.Width = width; image.Height = height; @@ -1589,8 +1585,7 @@ namespace Emby.Server.Implementations.Data if (!reader.IsDBNull(index)) { - ProgramAudio audio; - if (Enum.TryParse(reader.GetString(index), true, out audio)) + if (Enum.TryParse(reader.GetString(index), true, out ProgramAudio audio)) { item.Audio = audio; } @@ -1634,9 +1629,7 @@ namespace Emby.Server.Implementations.Data item.LockedFields = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select( i => { - MetadataFields parsedValue; - - if (Enum.TryParse(i, true, out parsedValue)) + if (Enum.TryParse(i, true, out MetadataFields parsedValue)) { return parsedValue; } @@ -1674,9 +1667,7 @@ namespace Emby.Server.Implementations.Data trailer.TrailerTypes = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select( i => { - TrailerType parsedValue; - - if (Enum.TryParse(i, true, out parsedValue)) + if (Enum.TryParse(i, true, out TrailerType parsedValue)) { return parsedValue; } @@ -1857,8 +1848,7 @@ namespace Emby.Server.Implementations.Data if (!reader.IsDBNull(index)) { - ExtraType extraType; - if (Enum.TryParse(reader.GetString(index), true, out extraType)) + if (Enum.TryParse(reader.GetString(index), true, out ExtraType extraType)) { item.ExtraType = extraType; } @@ -5149,8 +5139,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type private IEnumerable MapIncludeItemTypes(string value) { - string[] result; - if (_types.TryGetValue(value, out result)) + if (_types.TryGetValue(value, out var result)) { return result; } diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index 4f5950ac7..56e555937 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -25,8 +25,7 @@ namespace Emby.Server.Implementations.Devices { var value = File.ReadAllText(CachePath, Encoding.UTF8); - Guid guid; - if (Guid.TryParse(value, out guid)) + if (Guid.TryParse(value, out var guid)) { return value; } diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index f21daab62..f2ab28d4c 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -98,8 +98,7 @@ namespace Emby.Server.Implementations.Devices { lock (_capabilitiesSyncLock) { - ClientCapabilities result; - if (_capabilitiesCache.TryGetValue(id, out result)) + if (_capabilitiesCache.TryGetValue(id, out var result)) { return result; } diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 8877fc051..6cb820716 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -637,9 +637,7 @@ namespace Emby.Server.Implementations.Dto Type = person.Type }; - Person entity; - - if (dictionary.TryGetValue(person.Name, out entity)) + if (dictionary.TryGetValue(person.Name, out var entity)) { baseItemPerson.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary); baseItemPerson.Id = entity.Id.ToString("N"); diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 382861635..7faad05e3 100644 --- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -108,11 +108,9 @@ namespace Emby.Server.Implementations.EntryPoints var info = e.Argument; - string usn; - if (!info.Headers.TryGetValue("USN", out usn)) usn = string.Empty; + if (!info.Headers.TryGetValue("USN", out var usn)) usn = string.Empty; - string nt; - if (!info.Headers.TryGetValue("NT", out nt)) nt = string.Empty; + if (!info.Headers.TryGetValue("NT", out var nt)) nt = string.Empty; // Filter device type if (usn.IndexOf("WANIPConnection:", StringComparison.OrdinalIgnoreCase) == -1 && @@ -141,8 +139,7 @@ namespace Emby.Server.Implementations.EntryPoints _logger.LogDebug("Found NAT device: " + identifier); - IPAddress address; - if (IPAddress.TryParse(info.Location.Host, out address)) + if (IPAddress.TryParse(info.Location.Host, out var address)) { // The Handle method doesn't need the port var endpoint = new IPEndPoint(address, info.Location.Port); @@ -153,8 +150,7 @@ namespace Emby.Server.Implementations.EntryPoints { var localAddressString = await _appHost.GetLocalApiUrl(CancellationToken.None).ConfigureAwait(false); - Uri uri; - if (Uri.TryCreate(localAddressString, UriKind.Absolute, out uri)) + if (Uri.TryCreate(localAddressString, UriKind.Absolute, out var uri)) { localAddressString = uri.Host; diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index bcfcc339c..7a8b09cf7 100644 --- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -89,8 +89,7 @@ namespace Emby.Server.Implementations.EntryPoints var progress = e.Argument.Item2; - DateTime lastMessageSendTime; - if (_lastProgressMessageTimes.TryGetValue(item.Id, out lastMessageSendTime)) + if (_lastProgressMessageTimes.TryGetValue(item.Id, out var lastMessageSendTime)) { if (progress > 0 && progress < 100 && (DateTime.UtcNow - lastMessageSendTime).TotalMilliseconds < 1000) { diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index d6cf39d62..93e222ebe 100644 --- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -62,9 +62,7 @@ namespace Emby.Server.Implementations.EntryPoints UpdateTimer.Change(UpdateDuration, Timeout.Infinite); } - List keys; - - if (!_changedItems.TryGetValue(e.UserId, out keys)) + if (!_changedItems.TryGetValue(e.UserId, out var keys)) { keys = new List(); _changedItems[e.UserId] = keys; diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index 255e1476f..8b0012410 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -90,11 +90,9 @@ namespace Emby.Server.Implementations.HttpClientManager throw new ArgumentNullException(nameof(host)); } - HttpClientInfo client; - var key = host + enableHttpCompression; - if (!_httpClients.TryGetValue(key, out client)) + if (!_httpClients.TryGetValue(key, out var client)) { client = new HttpClientInfo(); diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 784b39735..6ae56c2ad 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -124,8 +124,7 @@ namespace Emby.Server.Implementations.HttpServer public Type GetServiceTypeByRequest(Type requestType) { - Type serviceType; - ServiceOperationsMap.TryGetValue(requestType, out serviceType); + ServiceOperationsMap.TryGetValue(requestType, out var serviceType); return serviceType; } @@ -215,8 +214,7 @@ namespace Emby.Server.Implementations.HttpServer var exceptionType = ex.GetType(); - int statusCode; - if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out statusCode)) + if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out var statusCode)) { if (ex is DirectoryNotFoundException) { @@ -704,8 +702,7 @@ namespace Emby.Server.Implementations.HttpServer return null; } - string contentType; - var restPath = ServiceHandler.FindMatchingRestPath(httpReq.HttpMethod, pathInfo, out contentType); + var restPath = ServiceHandler.FindMatchingRestPath(httpReq.HttpMethod, pathInfo, out var contentType); if (restPath != null) { @@ -731,8 +728,7 @@ namespace Emby.Server.Implementations.HttpServer private void RedirectToSecureUrl(IHttpRequest httpReq, IResponse httpRes, string url) { int currentPort; - Uri uri; - if (Uri.TryCreate(url, UriKind.Absolute, out uri)) + if (Uri.TryCreate(url, UriKind.Absolute, out var uri)) { currentPort = uri.Port; var builder = new UriBuilder(uri); diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index ce9dc9ad9..3cfa2bc75 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -96,8 +96,7 @@ namespace Emby.Server.Implementations.HttpServer responseHeaders = new Dictionary(); } - string expires; - if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires)) + if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires)) { responseHeaders["Expires"] = "-1"; } @@ -143,8 +142,7 @@ namespace Emby.Server.Implementations.HttpServer responseHeaders = new Dictionary(); } - string expires; - if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires)) + if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires)) { responseHeaders["Expires"] = "-1"; } @@ -188,8 +186,7 @@ namespace Emby.Server.Implementations.HttpServer responseHeaders = new Dictionary(); } - string expires; - if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires)) + if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires)) { responseHeaders["Expires"] = "-1"; } @@ -702,9 +699,7 @@ namespace Emby.Server.Implementations.HttpServer if (!string.IsNullOrEmpty(ifModifiedSinceHeader)) { - DateTime ifModifiedSince; - - if (DateTime.TryParse(ifModifiedSinceHeader, out ifModifiedSince)) + if (DateTime.TryParse(ifModifiedSinceHeader, out var ifModifiedSince)) { if (IsNotModified(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified)) { @@ -720,11 +715,9 @@ namespace Emby.Server.Implementations.HttpServer // Validate If-None-Match if ((hasCacheKey || !string.IsNullOrEmpty(ifNoneMatchHeader))) { - Guid ifNoneMatch; - ifNoneMatchHeader = (ifNoneMatchHeader ?? string.Empty).Trim('\"'); - if (Guid.TryParse(ifNoneMatchHeader, out ifNoneMatch)) + if (Guid.TryParse(ifNoneMatchHeader, out var ifNoneMatch)) { if (hasCacheKey && cacheKey.Equals(ifNoneMatch)) { diff --git a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs index edd2a394b..ed8644e33 100644 --- a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs +++ b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs @@ -56,9 +56,8 @@ namespace Emby.Server.Implementations.HttpServer } // Content length has to be explicitly set on on HttpListenerResponse or it won't be happy - string contentLength; - if (hasHeaders.Headers.TryGetValue("Content-Length", out contentLength) && !string.IsNullOrEmpty(contentLength)) + if (hasHeaders.Headers.TryGetValue("Content-Length", out var contentLength) && !string.IsNullOrEmpty(contentLength)) { var length = long.Parse(contentLength, UsCulture); diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs index c037292ff..499a334fc 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs @@ -207,8 +207,7 @@ namespace Emby.Server.Implementations.HttpServer.Security private static AuthenticationInfo GetTokenInfo(IRequest request) { - object info; - request.Items.TryGetValue("OriginalAuthenticationInfo", out info); + request.Items.TryGetValue("OriginalAuthenticationInfo", out var info); return info as AuthenticationInfo; } diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index ae4adda7c..cab41e65b 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -26,8 +26,7 @@ namespace Emby.Server.Implementations.HttpServer.Security public AuthorizationInfo GetAuthorizationInfo(IRequest requestContext) { - object cached; - if (requestContext.Items.TryGetValue("AuthorizationInfo", out cached)) + if (requestContext.Items.TryGetValue("AuthorizationInfo", out var cached)) { return (AuthorizationInfo)cached; } diff --git a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs index 2c7057222..81e11d312 100644 --- a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs @@ -31,8 +31,7 @@ namespace Emby.Server.Implementations.HttpServer.Security private AuthenticationInfo GetTokenInfo(IRequest request) { - object info; - request.Items.TryGetValue("OriginalAuthenticationInfo", out info); + request.Items.TryGetValue("OriginalAuthenticationInfo", out var info); return info as AuthenticationInfo; } diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index 2c92e6543..6a3204011 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -103,8 +103,7 @@ namespace Emby.Server.Implementations.IO // But if we make this delay too high, we risk missing legitimate changes, such as user adding a new file, or hand-editing metadata await Task.Delay(45000).ConfigureAwait(false); - string val; - _tempIgnoredPaths.TryRemove(path, out val); + _tempIgnoredPaths.TryRemove(path, out var val); if (refreshPath) { @@ -365,9 +364,7 @@ namespace Emby.Server.Implementations.IO /// The path. private void StopWatchingPath(string path) { - FileSystemWatcher watcher; - - if (_fileSystemWatchers.TryGetValue(path, out watcher)) + if (_fileSystemWatchers.TryGetValue(path, out var watcher)) { DisposeWatcher(watcher, true); } @@ -424,9 +421,7 @@ namespace Emby.Server.Implementations.IO /// The watcher. private void RemoveWatcherFromList(FileSystemWatcher watcher) { - FileSystemWatcher removed; - - _fileSystemWatchers.TryRemove(watcher.Path, out removed); + _fileSystemWatchers.TryRemove(watcher.Path, out var removed); } /// diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 0d25cbc92..9f999cb7f 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -432,8 +432,7 @@ namespace Emby.Server.Implementations.Library ItemRepository.DeleteItem(child.Id, CancellationToken.None); } - BaseItem removed; - _libraryItemsCache.TryRemove(item.Id, out removed); + _libraryItemsCache.TryRemove(item.Id, out var removed); ReportItemRemoved(item, parent); } @@ -1241,9 +1240,7 @@ namespace Emby.Server.Implementations.Library throw new ArgumentNullException(nameof(id)); } - BaseItem item; - - if (LibraryItemsCache.TryGetValue(id, out item)) + if (LibraryItemsCache.TryGetValue(id, out var item)) { return item; } diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index fb0f33a2f..321a82c78 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -777,8 +777,7 @@ namespace Emby.Server.Implementations.Library try { - ILiveStream info; - if (_openStreams.TryGetValue(id, out info)) + if (_openStreams.TryGetValue(id, out var info)) { return info; } @@ -810,9 +809,7 @@ namespace Emby.Server.Implementations.Library try { - ILiveStream liveStream; - - if (_openStreams.TryGetValue(id, out liveStream)) + if (_openStreams.TryGetValue(id, out var liveStream)) { liveStream.ConsumerCount--; diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 0ee53281d..f48d59040 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -395,8 +395,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private async Task GetEpgChannels(IListingsProvider provider, ListingsProviderInfo info, bool enableCache, CancellationToken cancellationToken) { - EpgChannelData result; - if (!enableCache || !_epgChannels.TryGetValue(info.Id, out result)) + if (!enableCache || !_epgChannels.TryGetValue(info.Id, out var result)) { var channels = await provider.GetChannels(info, cancellationToken).ConfigureAwait(false); @@ -652,9 +651,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV TimerCancelled(this, new GenericEventArgs(timerId)); } } - ActiveRecordingInfo activeRecordingInfo; - if (_activeRecordings.TryGetValue(timerId, out activeRecordingInfo)) + if (_activeRecordings.TryGetValue(timerId, out var activeRecordingInfo)) { activeRecordingInfo.Timer = timer; activeRecordingInfo.CancellationTokenSource.Cancel(); @@ -821,8 +819,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } // Only update if not currently active - ActiveRecordingInfo activeRecordingInfo; - if (!_activeRecordings.TryGetValue(updatedTimer.Id, out activeRecordingInfo)) + if (!_activeRecordings.TryGetValue(updatedTimer.Id, out var activeRecordingInfo)) { existingTimer.PrePaddingSeconds = updatedTimer.PrePaddingSeconds; existingTimer.PostPaddingSeconds = updatedTimer.PostPaddingSeconds; @@ -864,9 +861,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public string GetActiveRecordingPath(string id) { - ActiveRecordingInfo info; - - if (_activeRecordings.TryGetValue(id, out info)) + if (_activeRecordings.TryGetValue(id, out var info)) { return info.Path; } @@ -1440,8 +1435,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV TriggerRefresh(recordPath); _libraryMonitor.ReportFileSystemChangeComplete(recordPath, false); - ActiveRecordingInfo removed; - _activeRecordings.TryRemove(timer.Id, out removed); + _activeRecordings.TryRemove(timer.Id, out var removed); if (recordingStatus != RecordingStatus.Completed && DateTime.UtcNow < timer.EndDate && timer.RetryCount < 10) { @@ -2007,8 +2001,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV writer.WriteStartDocument(true); writer.WriteStartElement("tvshow"); - string id; - if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id)) + if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out var id)) { writer.WriteElementString("id", id); } @@ -2417,8 +2410,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { // Only update if not currently active - test both new timer and existing in case Id's are different // Id's could be different if the timer was created manually prior to series timer creation - ActiveRecordingInfo activeRecordingInfo; - if (!_activeRecordings.TryGetValue(timer.Id, out activeRecordingInfo) && !_activeRecordings.TryGetValue(existingTimer.Id, out activeRecordingInfo)) + if (!_activeRecordings.TryGetValue(timer.Id, out var activeRecordingInfo) && !_activeRecordings.TryGetValue(existingTimer.Id, out activeRecordingInfo)) { UpdateExistingTimerWithNewMetadata(existingTimer, timer); @@ -2521,9 +2513,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(Guid.Empty)) { - LiveTvChannel channel; - - if (!tempChannelCache.TryGetValue(parent.ChannelId, out channel)) + if (!tempChannelCache.TryGetValue(parent.ChannelId, out var channel)) { channel = _libraryManager.GetItemList(new InternalItemsQuery { @@ -2582,9 +2572,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (!programInfo.ChannelId.Equals(Guid.Empty)) { - LiveTvChannel channel; - - if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out channel)) + if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out var channel)) { channel = _libraryManager.GetItemList(new InternalItemsQuery { diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs index 9730d552d..7f67d70a9 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs @@ -140,8 +140,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private void StopTimer(TimerInfo item) { - ITimer timer; - if (_timers.TryRemove(item.Id, out timer)) + if (_timers.TryRemove(item.Id, out var timer)) { timer.Dispose(); } diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 379927191..6efbefd5d 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -528,8 +528,7 @@ namespace Emby.Server.Implementations.LiveTv var isNew = false; var forceUpdate = false; - LiveTvProgram item; - if (!allExistingPrograms.TryGetValue(id, out item)) + if (!allExistingPrograms.TryGetValue(id, out var item)) { isNew = true; item = new LiveTvProgram @@ -1940,8 +1939,7 @@ namespace Emby.Server.Implementations.LiveTv foreach (var programDto in currentProgramDtos) { - BaseItemDto channelDto; - if (currentChannelsDict.TryGetValue(programDto.ChannelId, out channelDto)) + if (currentChannelsDict.TryGetValue(programDto.ChannelId, out var channelDto)) { channelDto.CurrentProgram = programDto; } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 36f688c43..09d33342e 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -118,8 +118,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun { if (!string.IsNullOrEmpty(cacheKey)) { - DiscoverResponse response; - if (_modelCache.TryGetValue(cacheKey, out response)) + if (_modelCache.TryGetValue(cacheKey, out var response)) { return response; } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs index 67eeec21d..8268802fb 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs @@ -132,8 +132,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var receiveBuffer = new byte[8192]; var response = await socket.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false); - string returnVal; - ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal); + ParseReturnMessage(response.Buffer, response.ReceivedBytes, out var returnVal); return string.Equals(returnVal, "none", StringComparison.OrdinalIgnoreCase); } @@ -167,9 +166,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var lockkeyMsg = CreateSetMessage(i, "lockkey", lockKeyString, null); await tcpClient.SendToAsync(lockkeyMsg, 0, lockkeyMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false); var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false); - string returnVal; // parse response to make sure it worked - if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal)) + if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out var returnVal)) continue; var commandList = commands.GetCommands(); @@ -222,8 +220,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), cancellationToken).ConfigureAwait(false); var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false); // parse response to make sure it worked - string returnVal; - if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal)) + if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out var returnVal)) { return; } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 0772a6025..638796e2e 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -135,9 +135,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts var protocol = _mediaSourceManager.GetPathProtocol(path); - Uri uri; var isRemote = true; - if (Uri.TryCreate(path, UriKind.Absolute, out uri)) + if (Uri.TryCreate(path, UriKind.Absolute, out var uri)) { isRemote = !_networkManager.IsInLocalNetwork(uri.Host); } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 353b938c6..c1ee059f4 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -117,12 +117,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts extInf = extInf.Trim(); - string remaining; - var attributes = ParseExtInf(extInf, out remaining); + var attributes = ParseExtInf(extInf, out var remaining); extInf = remaining; - string value; - if (attributes.TryGetValue("tvg-logo", out value)) + if (attributes.TryGetValue("tvg-logo", out var value)) { channel.ImageUrl = value; } @@ -130,11 +128,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts channel.Name = GetChannelName(extInf, attributes); channel.Number = GetChannelNumber(extInf, attributes, mediaUrl); - string tvgId; - attributes.TryGetValue("tvg-id", out tvgId); + attributes.TryGetValue("tvg-id", out var tvgId); - string channelId; - attributes.TryGetValue("channel-id", out channelId); + attributes.TryGetValue("channel-id", out var channelId); channel.TunerChannelId = string.IsNullOrWhiteSpace(tvgId) ? channelId : tvgId; @@ -172,8 +168,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' }); - double number; - if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) + if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number)) { numberString = numberPart; } @@ -187,11 +182,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts if (!IsValidChannelNumber(numberString)) { - string value; - if (attributes.TryGetValue("tvg-id", out value)) + if (attributes.TryGetValue("tvg-id", out var value)) { - double doubleValue; - if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue)) + if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var doubleValue)) { numberString = value; } @@ -205,8 +198,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts if (!IsValidChannelNumber(numberString)) { - string value; - if (attributes.TryGetValue("channel-id", out value)) + if (attributes.TryGetValue("channel-id", out var value)) { numberString = value; } @@ -259,8 +251,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return false; } - double value; - if (!double.TryParse(numberString, NumberStyles.Any, CultureInfo.InvariantCulture, out value)) + if (!double.TryParse(numberString, NumberStyles.Any, CultureInfo.InvariantCulture, out var value)) { return false; } @@ -283,8 +274,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' }); - double number; - if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) + if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number)) { //channel.Number = number.ToString(); nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' }); @@ -292,8 +282,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } - string name; - attributes.TryGetValue("tvg-name", out name); + attributes.TryGetValue("tvg-name", out var name); if (string.IsNullOrWhiteSpace(name)) { diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index 998595ecd..b71e89c5a 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -298,9 +298,7 @@ namespace Emby.Server.Implementations.Localization /// The country code. private Dictionary GetRatings(string countryCode) { - Dictionary value; - - _allParentalRatings.TryGetValue(countryCode, out value); + _allParentalRatings.TryGetValue(countryCode, out var value); return value; } @@ -320,9 +318,7 @@ namespace Emby.Server.Implementations.Localization if (parts.Length == 2) { - int value; - - if (int.TryParse(parts[1], NumberStyles.Integer, UsCulture, out value)) + if (int.TryParse(parts[1], NumberStyles.Integer, UsCulture, out var value)) { return new ParentalRating { Name = parts[0], Value = value }; } @@ -364,9 +360,7 @@ namespace Emby.Server.Implementations.Localization var ratingsDictionary = GetParentalRatingsDictionary(); - ParentalRating value; - - if (ratingsDictionary.TryGetValue(rating, out value)) + if (ratingsDictionary.TryGetValue(rating, out var value)) { return value.Value; } @@ -427,9 +421,7 @@ namespace Emby.Server.Implementations.Localization var dictionary = GetLocalizationDictionary(culture); - string value; - - if (dictionary.TryGetValue(phrase, out value)) + if (dictionary.TryGetValue(phrase, out var value)) { return value; } 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 /// 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 /// 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 /// 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 /// 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 /// 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 /// 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 /// 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> _subnetLookup = new Dictionary>(StringComparer.Ordinal); private List GetSubnets(string endpointFirstPart) { - List 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 /// 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; diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs index ac47c9625..09c348e24 100644 --- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs +++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs @@ -364,8 +364,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { var list = new List>(); - Tuple item; - while (_taskQueue.TryDequeue(out item)) + while (_taskQueue.TryDequeue(out var item)) { if (list.All(i => i.Item1 != item.Item1)) { diff --git a/Emby.Server.Implementations/Security/MBLicenseFile.cs b/Emby.Server.Implementations/Security/MBLicenseFile.cs index 8273ec8b2..91fbb4a2c 100644 --- a/Emby.Server.Implementations/Security/MBLicenseFile.cs +++ b/Emby.Server.Implementations/Security/MBLicenseFile.cs @@ -68,9 +68,8 @@ namespace Emby.Server.Implementations.Security public void RemoveRegCheck(string featureId) { var key = GetKey(featureId); - FeatureRegInfo val; - _updateRecords.TryRemove(key, out val); + _updateRecords.TryRemove(key, out var val); Save(); } @@ -135,13 +134,11 @@ namespace Emby.Server.Implementations.Security continue; } - Guid feat; - if (Guid.TryParse(line, out feat)) + if (Guid.TryParse(line, out var feat)) { var lineParts = contents[i + 1].Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); - long ticks; - if (long.TryParse(lineParts[0], out ticks)) + if (long.TryParse(lineParts[0], out var ticks)) { var info = new FeatureRegInfo { diff --git a/Emby.Server.Implementations/Serialization/XmlSerializer.cs b/Emby.Server.Implementations/Serialization/XmlSerializer.cs index 210b5dfdd..22d6712ec 100644 --- a/Emby.Server.Implementations/Serialization/XmlSerializer.cs +++ b/Emby.Server.Implementations/Serialization/XmlSerializer.cs @@ -33,8 +33,7 @@ namespace Emby.Server.Implementations.Serialization var key = type.FullName; lock (_serializers) { - XmlSerializer serializer; - if (!_serializers.TryGetValue(key, out serializer)) + if (!_serializers.TryGetValue(key, out var serializer)) { serializer = new XmlSerializer(type); _serializers[key] = serializer; diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index b34832f45..9afa7f502 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -89,8 +89,7 @@ namespace Emby.Server.Implementations.Services if (restPath.Path.IndexOfAny(InvalidRouteChars) != -1) throw new ArgumentException(string.Format("Route '{0}' on '{1}' contains invalid chars. ", restPath.Path, restPath.RequestType.GetMethodName())); - List pathsAtFirstMatch; - if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out pathsAtFirstMatch)) + if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out var pathsAtFirstMatch)) { pathsAtFirstMatch = new List(); RestPathMap[restPath.FirstMatchHashKey] = pathsAtFirstMatch; diff --git a/Emby.Server.Implementations/Services/ServiceExec.cs b/Emby.Server.Implementations/Services/ServiceExec.cs index 2791ee2ac..0f2247a01 100644 --- a/Emby.Server.Implementations/Services/ServiceExec.cs +++ b/Emby.Server.Implementations/Services/ServiceExec.cs @@ -73,8 +73,7 @@ namespace Emby.Server.Implementations.Services { var actionName = request.Verb ?? "POST"; - ServiceMethod actionContext; - if (ServiceExecGeneral.execMap.TryGetValue(ServiceMethod.Key(serviceType, actionName, requestName), out actionContext)) + if (ServiceExecGeneral.execMap.TryGetValue(ServiceMethod.Key(serviceType, actionName, requestName), out var actionContext)) { if (actionContext.RequestFilters != null) { diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index c1c42e3ec..dcf4f4172 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -62,8 +62,7 @@ namespace Emby.Server.Implementations.Services { if (this.RestPath == null) { - string contentType; - this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, out contentType); + this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, out var contentType); if (contentType != null) ResponseContentType = contentType; @@ -137,9 +136,8 @@ namespace Emby.Server.Implementations.Services public static object CreateRequest(IRequest httpReq, RestPath restPath, Dictionary requestParams, object requestDto) { - string contentType; var pathInfo = !restPath.IsWildCardPath - ? GetSanitizedPathInfo(httpReq.PathInfo, out contentType) + ? GetSanitizedPathInfo(httpReq.PathInfo, out var contentType) : httpReq.PathInfo; return restPath.CreateRequest(pathInfo, requestParams, requestDto); @@ -239,8 +237,7 @@ namespace Emby.Server.Implementations.Services private static RestPath GetRoute(IRequest req) { - object route; - req.Items.TryGetValue("__route", out route); + req.Items.TryGetValue("__route", out var route); return route as RestPath; } } diff --git a/Emby.Server.Implementations/Services/ServicePath.cs b/Emby.Server.Implementations/Services/ServicePath.cs index 8ad31c160..7e1993b71 100644 --- a/Emby.Server.Implementations/Services/ServicePath.cs +++ b/Emby.Server.Implementations/Services/ServicePath.cs @@ -306,8 +306,7 @@ namespace Emby.Server.Implementations.Services public int MatchScore(string httpMethod, string[] withPathInfoParts) { - int wildcardMatchCount; - var isMatch = IsMatch(httpMethod, withPathInfoParts, out wildcardMatchCount); + var isMatch = IsMatch(httpMethod, withPathInfoParts, out var wildcardMatchCount); if (!isMatch) { return -1; @@ -484,8 +483,7 @@ namespace Emby.Server.Implementations.Services continue; } - string propertyNameOnRequest; - if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out propertyNameOnRequest)) + if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out var propertyNameOnRequest)) { if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase)) { diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index e398b58cc..e60593198 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -265,8 +265,7 @@ namespace Emby.Server.Implementations.Session { var key = GetSessionKey(session.Client, session.DeviceId); - SessionInfo removed; - _activeConnections.TryRemove(key, out removed); + _activeConnections.TryRemove(key, out var removed); OnSessionEnded(session); } @@ -281,8 +280,7 @@ namespace Emby.Server.Implementations.Session { var key = GetSessionKey(session.Client, session.DeviceId); - SessionInfo removed; - _activeConnections.TryRemove(key, out removed); + _activeConnections.TryRemove(key, out var removed); OnSessionEnded(session); } diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/ProbVector.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/ProbVector.cs index 7ad16108a..d7afb4113 100644 --- a/Emby.Server.Implementations/TextEncoding/NLangDetect/ProbVector.cs +++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/ProbVector.cs @@ -11,9 +11,7 @@ namespace NLangDetect.Core { get { - double value; - - return _dict.TryGetValue(key, out value) ? value : 0.0; + return _dict.TryGetValue(key, out var value) ? value : 0.0; } set diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs index d7dab8528..879c0a09b 100644 --- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs +++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs @@ -18,10 +18,8 @@ namespace NLangDetect.Core.Utils public static string getString(string key) { - string value; - return - _messages.TryGetValue(key, out value) + _messages.TryGetValue(key, out var value) ? value : string.Format("!{0}!", key); } diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 68cb7821d..6ed6f127b 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -317,9 +317,7 @@ namespace Emby.Server.Implementations.Updates return true; } - Version requiredVersion; - - return Version.TryParse(packageVersionInfo.requiredVersionStr, out requiredVersion) && currentServerVersion >= requiredVersion; + return Version.TryParse(packageVersionInfo.requiredVersionStr, out var requiredVersion) && currentServerVersion >= requiredVersion; } /// diff --git a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs index 8234393c2..52e58ed8d 100644 --- a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs +++ b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs @@ -140,8 +140,7 @@ namespace Emby.XmlTv.Classes private void SetChannelNumber(XmlTvChannel channel, string value) { value = value.Replace("-", "."); - double number; - if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) + if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var number)) { channel.Number = value; } @@ -426,8 +425,7 @@ namespace Emby.XmlTv.Classes if (textValue.Contains("/")) { var components = textValue.Split('/'); - float value; - if (float.TryParse(components[0], out value)) + if (float.TryParse(components[0], out var value)) { result.StarRating = value; } @@ -1053,8 +1051,7 @@ namespace Emby.XmlTv.Classes } var standardDate = string.Format("{0} {1}", dateComponent, dateOffset); - DateTimeOffset parsedDateTime; - if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out parsedDateTime)) + if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out var parsedDateTime)) { return parsedDateTime.ToUniversalTime(); } diff --git a/Jellyfin.Server/SocketSharp/RequestMono.cs b/Jellyfin.Server/SocketSharp/RequestMono.cs index 0e3d2ad65..45cb323d2 100644 --- a/Jellyfin.Server/SocketSharp/RequestMono.cs +++ b/Jellyfin.Server/SocketSharp/RequestMono.cs @@ -148,9 +148,7 @@ namespace Jellyfin.SocketSharp internal static bool IsInvalidString(string val) { - int validationFailureIndex; - - return IsInvalidString(val, out validationFailureIndex); + return IsInvalidString(val, out var validationFailureIndex); } internal static bool IsInvalidString(string val, out int validationFailureIndex) diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 0c3431e97..4e2380cfa 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -101,8 +101,7 @@ namespace MediaBrowser.Api { lock (_transcodingLocks) { - SemaphoreSlim result; - if (!_transcodingLocks.TryGetValue(outputPath, out result)) + if (!_transcodingLocks.TryGetValue(outputPath, out var result)) { result = new SemaphoreSlim(1, 1); _transcodingLocks[outputPath] = result; diff --git a/MediaBrowser.Api/IHasItemFields.cs b/MediaBrowser.Api/IHasItemFields.cs index 6b7a64389..8598ea262 100644 --- a/MediaBrowser.Api/IHasItemFields.cs +++ b/MediaBrowser.Api/IHasItemFields.cs @@ -37,9 +37,7 @@ namespace MediaBrowser.Api return val.Split(',').Select(v => { - ItemFields value; - - if (Enum.TryParse(v, true, out value)) + if (Enum.TryParse(v, true, out ItemFields value)) { return (ItemFields?)value; } diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 418ed18d6..369e9781f 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -659,8 +659,7 @@ namespace MediaBrowser.Api.Images { if (!string.IsNullOrWhiteSpace(request.Format)) { - ImageFormat format; - if (Enum.TryParse(request.Format, true, out format)) + if (Enum.TryParse(request.Format, true, out ImageFormat format)) { return new ImageFormat[] { format }; } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6d4af16e7..bb525adc7 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -531,8 +531,7 @@ namespace MediaBrowser.Api.Playback { if (!string.IsNullOrWhiteSpace(val) && videoRequest != null) { - SubtitleDeliveryMethod method; - if (Enum.TryParse(val, out method)) + if (Enum.TryParse(val, out SubtitleDeliveryMethod method)) { videoRequest.SubtitleMethod = method; } @@ -636,8 +635,7 @@ namespace MediaBrowser.Api.Playback if (value.IndexOf(':') == -1) { // Parses npt times in the format of '417.33' - double seconds; - if (double.TryParse(value, NumberStyles.Any, UsCulture, out seconds)) + if (double.TryParse(value, NumberStyles.Any, UsCulture, out var seconds)) { return TimeSpan.FromSeconds(seconds).Ticks; } @@ -652,8 +650,7 @@ namespace MediaBrowser.Api.Playback foreach (var time in tokens) { - double digit; - if (double.TryParse(time, NumberStyles.Any, UsCulture, out digit)) + if (double.TryParse(time, NumberStyles.Any, UsCulture, out var digit)) { secondsSum += digit * timeFactor; } diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index ded82c19b..234ada6c0 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -413,10 +413,9 @@ namespace MediaBrowser.Api.Session /// The request. public Task Post(SendSystemCommand request) { - GeneralCommandType commandType; var name = request.Command; - if (Enum.TryParse(name, true, out commandType)) + if (Enum.TryParse(name, true, out GeneralCommandType commandType)) { name = commandType.ToString(); } diff --git a/MediaBrowser.Common/Net/HttpRequestOptions.cs b/MediaBrowser.Common/Net/HttpRequestOptions.cs index 0b21472f0..dadac5e03 100644 --- a/MediaBrowser.Common/Net/HttpRequestOptions.cs +++ b/MediaBrowser.Common/Net/HttpRequestOptions.cs @@ -102,9 +102,7 @@ namespace MediaBrowser.Common.Net private string GetHeaderValue(string name) { - string value; - - RequestHeaders.TryGetValue(name, out value); + RequestHeaders.TryGetValue(name, out var value); return value; } diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index c56dc04ec..91cfcd0ce 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -103,8 +103,7 @@ namespace MediaBrowser.Controller.Entities { lock (LibraryOptions) { - LibraryOptions options; - if (!LibraryOptions.TryGetValue(path, out options)) + if (!LibraryOptions.TryGetValue(path, out var options)) { options = LoadLibraryOptions(path); LibraryOptions[path] = options; diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index bbee594f6..b40bccde6 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -331,9 +331,7 @@ namespace MediaBrowser.Controller.Entities foreach (var child in nonCachedChildren) { - BaseItem currentChild; - - if (currentChildren.TryGetValue(child.Id, out currentChild)) + if (currentChildren.TryGetValue(child.Id, out var currentChild)) { validChildren.Add(currentChild); diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index 643c0ddcf..cad5ed863 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -50,11 +50,9 @@ namespace MediaBrowser.Controller.Entities public IList GetTaggedItems(InternalItemsQuery query) { - int year; - var usCulture = new CultureInfo("en-US"); - if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out year)) + if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out var year)) { return new List(); } @@ -66,9 +64,7 @@ namespace MediaBrowser.Controller.Entities public int? GetYearValue() { - int i; - - if (int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out i)) + if (int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out var i)) { return i; } diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs index 223761654..3080143ce 100644 --- a/MediaBrowser.Controller/Library/TVUtils.cs +++ b/MediaBrowser.Controller/Library/TVUtils.cs @@ -40,9 +40,7 @@ namespace MediaBrowser.Controller.Library }; } - DayOfWeek value; - - if (Enum.TryParse(day, true, out value)) + if (Enum.TryParse(day, true, out DayOfWeek value)) { return new DayOfWeek[] { diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 3bc43143f..edc43ef46 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -943,9 +943,7 @@ namespace MediaBrowser.Controller.MediaEncoding var level = state.GetRequestedLevel(videoStream.Codec); if (!string.IsNullOrEmpty(level)) { - double requestLevel; - - if (double.TryParse(level, NumberStyles.Any, _usCulture, out requestLevel)) + if (double.TryParse(level, NumberStyles.Any, _usCulture, out var requestLevel)) { if (!videoStream.Level.HasValue) { diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index bb09d365e..ea8a79306 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -193,8 +193,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(codec)) { var value = BaseRequest.GetOption(codec, "maxrefframes"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -213,8 +212,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(codec)) { var value = BaseRequest.GetOption(codec, "videobitdepth"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -233,8 +231,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(codec)) { var value = BaseRequest.GetOption(codec, "audiobitdepth"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -257,8 +254,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(codec)) { var value = BaseRequest.GetOption(codec, "audiochannels"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -419,8 +415,7 @@ namespace MediaBrowser.Controller.MediaEncoding } var level = GetRequestedLevel(ActualOutputVideoCodec); - double result; - if (!string.IsNullOrEmpty(level) && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(level) && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs index 625f0b389..ff54bb393 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs @@ -228,8 +228,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetOption(string name) { - string value; - if (StreamOptions.TryGetValue(name, out value)) + if (StreamOptions.TryGetValue(name, out var value)) { return value; } diff --git a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs index a379efafa..b812a8ddc 100644 --- a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs +++ b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs @@ -74,9 +74,8 @@ namespace MediaBrowser.Controller.MediaEncoding (i + 1 < parts.Length)) { var rate = parts[i + 1]; - float val; - if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val)) + if (float.TryParse(rate, NumberStyles.Any, _usCulture, out var val)) { framerate = val; } @@ -85,9 +84,8 @@ namespace MediaBrowser.Controller.MediaEncoding part.StartsWith("time=", StringComparison.OrdinalIgnoreCase)) { var time = part.Split(new[] { '=' }, 2).Last(); - TimeSpan val; - if (TimeSpan.TryParse(time, _usCulture, out val)) + if (TimeSpan.TryParse(time, _usCulture, out var val)) { var currentMs = startMs + val.TotalMilliseconds; @@ -110,9 +108,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (scale.HasValue) { - long val; - - if (long.TryParse(size, NumberStyles.Any, _usCulture, out val)) + if (long.TryParse(size, NumberStyles.Any, _usCulture, out var val)) { bytesTranscoded = val * scale.Value; } @@ -131,9 +127,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (scale.HasValue) { - float val; - - if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val)) + if (float.TryParse(rate, NumberStyles.Any, _usCulture, out var val)) { bitRate = (int)Math.Ceiling(val * scale.Value); } diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 622bba637..ab3196aba 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -25,9 +25,7 @@ namespace MediaBrowser.Controller.Providers public FileSystemMetadata[] GetFileSystemEntries(string path) { - FileSystemMetadata[] entries; - - if (!_cache.TryGetValue(path, out entries)) + if (!_cache.TryGetValue(path, out var entries)) { //_logger.LogDebug("Getting files for " + path); @@ -56,8 +54,7 @@ namespace MediaBrowser.Controller.Providers public FileSystemMetadata GetFile(string path) { - FileSystemMetadata file; - if (!_fileCache.TryGetValue(path, out file)) + if (!_fileCache.TryGetValue(path, out var file)) { file = _fileSystem.GetFileInfo(path); @@ -83,8 +80,7 @@ namespace MediaBrowser.Controller.Providers public List GetFilePaths(string path, bool clearCache) { - List result; - if (clearCache || !_filePathCache.TryGetValue(path, out result)) + if (clearCache || !_filePathCache.TryGetValue(path, out var result)) { result = _fileSystem.GetFilePaths(path).ToList(); diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index 0ee283325..821b11a5d 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -151,8 +151,7 @@ namespace MediaBrowser.LocalMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - DateTime added; - if (DateTime.TryParse(val, out added)) + if (DateTime.TryParse(val, out var added)) { item.DateCreated = added.ToUniversalTime(); } @@ -185,8 +184,7 @@ namespace MediaBrowser.LocalMetadata.Parsers if (!string.IsNullOrEmpty(text)) { - float value; - if (float.TryParse(text, NumberStyles.Any, _usCulture, out value)) + if (float.TryParse(text, NumberStyles.Any, _usCulture, out var value)) { item.CriticRating = value; } @@ -261,9 +259,7 @@ namespace MediaBrowser.LocalMetadata.Parsers { item.LockedFields = val.Split('|').Select(i => { - MetadataFields field; - - if (Enum.TryParse(i, true, out field)) + if (Enum.TryParse(i, true, out MetadataFields field)) { return (MetadataFields?)field; } @@ -337,8 +333,7 @@ namespace MediaBrowser.LocalMetadata.Parsers if (!string.IsNullOrWhiteSpace(text)) { - int runtime; - if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out runtime)) + if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out var runtime)) { item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks; } @@ -494,8 +489,7 @@ namespace MediaBrowser.LocalMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int productionYear; - if (int.TryParse(val, out productionYear) && productionYear > 1850) + if (int.TryParse(val, out var productionYear) && productionYear > 1850) { item.ProductionYear = productionYear; } @@ -512,9 +506,8 @@ namespace MediaBrowser.LocalMetadata.Parsers if (!string.IsNullOrWhiteSpace(rating)) { - float val; // All external meta is saving this as '.' for decimal I believe...but just to be sure - if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out val)) + if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var val)) { item.CommunityRating = val; } @@ -530,9 +523,7 @@ namespace MediaBrowser.LocalMetadata.Parsers if (!string.IsNullOrWhiteSpace(firstAired)) { - DateTime airDate; - - if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out airDate) && airDate.Year > 1850) + if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var airDate) && airDate.Year > 1850) { item.PremiereDate = airDate.ToUniversalTime(); item.ProductionYear = airDate.Year; @@ -549,9 +540,7 @@ namespace MediaBrowser.LocalMetadata.Parsers if (!string.IsNullOrWhiteSpace(firstAired)) { - DateTime airDate; - - if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out airDate) && airDate.Year > 1850) + if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var airDate) && airDate.Year > 1850) { item.EndDate = airDate.ToUniversalTime(); } @@ -687,8 +676,7 @@ namespace MediaBrowser.LocalMetadata.Parsers default: { string readerName = reader.Name; - string providerIdValue; - if (_validProviderIds.TryGetValue(readerName, out providerIdValue)) + if (_validProviderIds.TryGetValue(readerName, out var providerIdValue)) { var id = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(id)) @@ -1127,8 +1115,7 @@ namespace MediaBrowser.LocalMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int intVal; - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out intVal)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var intVal)) { sortOrder = intVal; } diff --git a/MediaBrowser.LocalMetadata/Parsers/GameXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/GameXmlParser.cs index cc908b97b..df7c51f27 100644 --- a/MediaBrowser.LocalMetadata/Parsers/GameXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/GameXmlParser.cs @@ -63,9 +63,7 @@ namespace MediaBrowser.LocalMetadata.Parsers var val = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(val)) { - int num; - - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out num)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var num)) { item.PlayersSupported = num; } diff --git a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs index f4d0899b6..e4eabaf38 100644 --- a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs +++ b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs @@ -52,9 +52,7 @@ namespace MediaBrowser.MediaEncoding.Probing return null; } - string val; - - tags.TryGetValue(key, out val); + tags.TryGetValue(key, out var val); return val; } @@ -70,9 +68,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(val)) { - int i; - - if (int.TryParse(val, out i)) + if (int.TryParse(val, out var i)) { return i; } @@ -93,9 +89,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(val)) { - DateTime i; - - if (DateTime.TryParse(val, out i)) + if (DateTime.TryParse(val, out var i)) { return i.ToUniversalTime(); } diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 7b8964707..b72ad572a 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -52,8 +52,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(data.format.bit_rate)) { - int value; - if (int.TryParse(data.format.bit_rate, NumberStyles.Any, _usCulture, out value)) + if (int.TryParse(data.format.bit_rate, NumberStyles.Any, _usCulture, out var value)) { info.Bitrate = value; } @@ -579,8 +578,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(streamInfo.sample_rate)) { - int value; - if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out value)) + if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out var value)) { stream.SampleRate = value; } @@ -669,8 +667,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(streamInfo.bit_rate)) { - int value; - if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out value)) + if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out var value)) { bitrate = value; } @@ -679,8 +676,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (bitrate == 0 && formatInfo != null && !string.IsNullOrEmpty(formatInfo.bit_rate) && stream.Type == MediaStreamType.Video) { // If the stream info doesn't have a bitrate get the value from the media format info - int value; - if (int.TryParse(formatInfo.bit_rate, NumberStyles.Any, _usCulture, out value)) + if (int.TryParse(formatInfo.bit_rate, NumberStyles.Any, _usCulture, out var value)) { bitrate = value; } @@ -732,9 +728,7 @@ namespace MediaBrowser.MediaEncoding.Probing return null; } - string val; - - tags.TryGetValue(key, out val); + tags.TryGetValue(key, out var val); return val; } @@ -752,13 +746,10 @@ namespace MediaBrowser.MediaEncoding.Probing { var original = info.display_aspect_ratio; - int height; - int width; - var parts = (original ?? string.Empty).Split(':'); if (!(parts.Length == 2 && - int.TryParse(parts[0], NumberStyles.Any, _usCulture, out width) && - int.TryParse(parts[1], NumberStyles.Any, _usCulture, out height) && + int.TryParse(parts[0], NumberStyles.Any, _usCulture, out var width) && + int.TryParse(parts[1], NumberStyles.Any, _usCulture, out var height) && width > 0 && height > 0)) { @@ -1187,9 +1178,7 @@ namespace MediaBrowser.MediaEncoding.Probing { disc = disc.Split('/')[0]; - int num; - - if (int.TryParse(disc, out num)) + if (int.TryParse(disc, out var num)) { return num; } @@ -1204,8 +1193,7 @@ namespace MediaBrowser.MediaEncoding.Probing if (chapter.tags != null) { - string name; - if (chapter.tags.TryGetValue("title", out name)) + if (chapter.tags.TryGetValue("title", out var name)) { info.Name = name; } @@ -1213,9 +1201,8 @@ namespace MediaBrowser.MediaEncoding.Probing // Limit accuracy to milliseconds to match xml saving var secondsString = chapter.start_time; - double seconds; - if (double.TryParse(secondsString, NumberStyles.Any, CultureInfo.InvariantCulture, out seconds)) + if (double.TryParse(secondsString, NumberStyles.Any, CultureInfo.InvariantCulture, out var seconds)) { var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds); info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks; @@ -1269,9 +1256,7 @@ namespace MediaBrowser.MediaEncoding.Probing var year = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime"); if (!string.IsNullOrWhiteSpace(year)) { - int val; - - if (int.TryParse(year, NumberStyles.Integer, _usCulture, out val)) + if (int.TryParse(year, NumberStyles.Integer, _usCulture, out var val)) { video.ProductionYear = val; } @@ -1280,11 +1265,9 @@ namespace MediaBrowser.MediaEncoding.Probing var premiereDateString = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaOriginalBroadcastDateTime"); if (!string.IsNullOrWhiteSpace(premiereDateString)) { - DateTime val; - // Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/ // DateTime is reported along with timezone info (typically Z i.e. UTC hence assume None) - if (DateTime.TryParse(year, null, DateTimeStyles.None, out val)) + if (DateTime.TryParse(year, null, DateTimeStyles.None, out var val)) { video.PremiereDate = val.ToUniversalTime(); } diff --git a/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs b/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs index 7f312eaec..605504418 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs @@ -61,8 +61,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles long GetTicks(string time) { - TimeSpan span; - return TimeSpan.TryParseExact(time, @"h\:mm\:ss\.ff", _usCulture, out span) + return TimeSpan.TryParseExact(time, @"h\:mm\:ss\.ff", _usCulture, out var span) ? span.Ticks : 0; } diff --git a/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs b/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs index 02ce71ec3..0606dbdb2 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs @@ -83,8 +83,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles long GetTicks(string time) { - TimeSpan span; - return TimeSpan.TryParseExact(time, @"hh\:mm\:ss\.fff", _usCulture, out span) + return TimeSpan.TryParseExact(time, @"hh\:mm\:ss\.fff", _usCulture, out var span) ? span.Ticks : (TimeSpan.TryParseExact(time, @"hh\:mm\:ss\,fff", _usCulture, out span) ? span.Ticks : 0); diff --git a/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs b/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs index 8281de764..2c18a02ef 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs @@ -288,8 +288,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles private static bool IsInteger(string s) { - int i; - if (int.TryParse(s, out i)) + if (int.TryParse(s, out var i)) return true; return false; } diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs index b3d035be2..808c0ed65 100644 --- a/MediaBrowser.Model/Configuration/LibraryOptions.cs +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -108,8 +108,7 @@ namespace MediaBrowser.Model.Configuration } } - ImageOption[] options; - if (DefaultImageOptions.TryGetValue(Type, out options)) + if (DefaultImageOptions.TryGetValue(Type, out var options)) { foreach (var i in options) { diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs index ae7d17275..dc0c5f139 100644 --- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs +++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs @@ -129,8 +129,7 @@ namespace MediaBrowser.Model.Dlna return !condition.IsRequired; } - int expected; - if (int.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out expected)) + if (int.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected)) { switch (condition.Condition) { @@ -184,8 +183,7 @@ namespace MediaBrowser.Model.Dlna return !condition.IsRequired; } - bool expected; - if (bool.TryParse(condition.Value, out expected)) + if (bool.TryParse(condition.Value, out var expected)) { switch (condition.Condition) { @@ -209,8 +207,7 @@ namespace MediaBrowser.Model.Dlna return !condition.IsRequired; } - float expected; - if (float.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out expected)) + if (float.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected)) { switch (condition.Condition) { @@ -238,8 +235,7 @@ namespace MediaBrowser.Model.Dlna return !condition.IsRequired; } - double expected; - if (double.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out expected)) + if (double.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected)) { switch (condition.Condition) { diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 2335f0553..4f4054db4 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -688,8 +688,7 @@ namespace MediaBrowser.Model.Dlna if (!string.IsNullOrEmpty(transcodingProfile.MaxAudioChannels)) { - int transcodingMaxAudioChannels; - if (int.TryParse(transcodingProfile.MaxAudioChannels, NumberStyles.Any, CultureInfo.InvariantCulture, out transcodingMaxAudioChannels)) + if (int.TryParse(transcodingProfile.MaxAudioChannels, NumberStyles.Any, CultureInfo.InvariantCulture, out var transcodingMaxAudioChannels)) { playlistItem.TranscodingMaxAudioChannels = transcodingMaxAudioChannels; } @@ -1491,8 +1490,7 @@ namespace MediaBrowser.Model.Dlna continue; } - int num; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { @@ -1526,8 +1524,7 @@ namespace MediaBrowser.Model.Dlna } } - int num; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { @@ -1551,8 +1548,7 @@ namespace MediaBrowser.Model.Dlna continue; } - bool isAvc; - if (bool.TryParse(value, out isAvc)) + if (bool.TryParse(value, out var isAvc)) { if (isAvc && condition.Condition == ProfileConditionType.Equals) { @@ -1572,8 +1568,7 @@ namespace MediaBrowser.Model.Dlna continue; } - bool isAnamorphic; - if (bool.TryParse(value, out isAnamorphic)) + if (bool.TryParse(value, out var isAnamorphic)) { if (isAnamorphic && condition.Condition == ProfileConditionType.Equals) { @@ -1603,8 +1598,7 @@ namespace MediaBrowser.Model.Dlna } } - bool isInterlaced; - if (bool.TryParse(value, out isInterlaced)) + if (bool.TryParse(value, out var isInterlaced)) { if (!isInterlaced && condition.Condition == ProfileConditionType.Equals) { @@ -1645,8 +1639,7 @@ namespace MediaBrowser.Model.Dlna } } - int num; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { @@ -1680,8 +1673,7 @@ namespace MediaBrowser.Model.Dlna } } - int num; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { @@ -1727,8 +1719,7 @@ namespace MediaBrowser.Model.Dlna continue; } - int num; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { @@ -1752,8 +1743,7 @@ namespace MediaBrowser.Model.Dlna continue; } - int num; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { @@ -1777,8 +1767,7 @@ namespace MediaBrowser.Model.Dlna continue; } - float num; - if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { @@ -1802,8 +1791,7 @@ namespace MediaBrowser.Model.Dlna continue; } - int num; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { @@ -1827,8 +1815,7 @@ namespace MediaBrowser.Model.Dlna continue; } - int num; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num)) { if (condition.Condition == ProfileConditionType.Equals) { diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 84bd1f429..99c545cc0 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -56,8 +56,7 @@ namespace MediaBrowser.Model.Dlna public string GetOption(string name) { - string value; - if (StreamOptions.TryGetValue(name, out value)) + if (StreamOptions.TryGetValue(name, out var value)) { return value; } @@ -622,8 +621,7 @@ namespace MediaBrowser.Model.Dlna return null; } - int result; - if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) + if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -639,8 +637,7 @@ namespace MediaBrowser.Model.Dlna return null; } - int result; - if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) + if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -656,8 +653,7 @@ namespace MediaBrowser.Model.Dlna return null; } - double result; - if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -673,8 +669,7 @@ namespace MediaBrowser.Model.Dlna return null; } - int result; - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -781,8 +776,7 @@ namespace MediaBrowser.Model.Dlna return defaultValue; } - int result; - if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) + if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return Math.Min(result, defaultValue ?? result); } diff --git a/MediaBrowser.Model/Drawing/ImageSize.cs b/MediaBrowser.Model/Drawing/ImageSize.cs index b27df346c..87764bbf4 100644 --- a/MediaBrowser.Model/Drawing/ImageSize.cs +++ b/MediaBrowser.Model/Drawing/ImageSize.cs @@ -69,9 +69,7 @@ namespace MediaBrowser.Model.Drawing if (parts.Length == 2) { - double val; - - if (double.TryParse(parts[0], NumberStyles.Any, CultureInfo.InvariantCulture, out val)) + if (double.TryParse(parts[0], NumberStyles.Any, CultureInfo.InvariantCulture, out var val)) { _width = val; } diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs index 3957f9dbe..437572d57 100644 --- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs +++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs @@ -48,8 +48,7 @@ namespace MediaBrowser.Model.Entities return null; } - string id; - instance.ProviderIds.TryGetValue(name, out id); + instance.ProviderIds.TryGetValue(name, out var id); return id; } diff --git a/MediaBrowser.Model/Net/MimeTypes.cs b/MediaBrowser.Model/Net/MimeTypes.cs index 77cba0f71..3891417c7 100644 --- a/MediaBrowser.Model/Net/MimeTypes.cs +++ b/MediaBrowser.Model/Net/MimeTypes.cs @@ -132,8 +132,7 @@ namespace MediaBrowser.Model.Net var ext = Path.GetExtension(path) ?? string.Empty; - string result; - if (MimeTypeLookup.TryGetValue(ext, out result)) + if (MimeTypeLookup.TryGetValue(ext, out var result)) { return result; } @@ -339,8 +338,7 @@ namespace MediaBrowser.Model.Net // handle text/html; charset=UTF-8 mimeType = mimeType.Split(';')[0]; - string result; - if (ExtensionLookup.TryGetValue(mimeType, out result)) + if (ExtensionLookup.TryGetValue(mimeType, out var result)) { return result; } diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index ec6ecaad3..915c260bf 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -968,8 +968,7 @@ namespace MediaBrowser.Providers.Manager { lock (_activeRefreshes) { - double value; - if (_activeRefreshes.TryGetValue(id, out value)) + if (_activeRefreshes.TryGetValue(id, out var value)) { return value; } @@ -1029,7 +1028,6 @@ namespace MediaBrowser.Providers.Manager private async Task StartProcessingRefreshQueue() { - Tuple refreshItem; var libraryManager = _libraryManagerFactory(); if (_disposed) @@ -1039,7 +1037,7 @@ namespace MediaBrowser.Providers.Manager var cancellationToken = _disposeCancellationTokenSource.Token; - while (_refreshQueue.TryDequeue(out refreshItem)) + while (_refreshQueue.TryDequeue(out var refreshItem)) { if (_disposed) { diff --git a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs index 71e979e2c..b67edf50a 100644 --- a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs @@ -133,8 +133,7 @@ namespace Priority_Queue return false; } - SimpleNode node; - if (_queue.TryDequeue(out node)) + if (_queue.TryDequeue(out var node)) { item = node.Data; return true; diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 45d3b11b6..80c93f157 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -251,12 +251,10 @@ namespace MediaBrowser.Providers.MediaInfo foreach (var chapter in chapters) { - TimeSpan time; - // Check if the name is empty and/or if the name is a time // Some ripping programs do that. if (string.IsNullOrWhiteSpace(chapter.Name) || - TimeSpan.TryParse(chapter.Name, out time)) + TimeSpan.TryParse(chapter.Name, out var time)) { chapter.Name = string.Format(_localization.GetLocalizedString("ChapterNameValue"), index.ToString(CultureInfo.InvariantCulture)); } diff --git a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs index 79e61f6a7..63d99db9b 100644 --- a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs +++ b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs @@ -168,7 +168,6 @@ namespace MediaBrowser.Providers.Movies if (!string.IsNullOrEmpty(url)) { var likesString = i.likes; - int likes; var info = new RemoteImageInfo { @@ -181,7 +180,7 @@ namespace MediaBrowser.Providers.Movies Language = i.lang }; - if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out likes)) + if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out var likes)) { info.CommunityRating = likes; } diff --git a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs index ff294966b..10d3e5e9d 100644 --- a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs +++ b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs @@ -161,10 +161,9 @@ namespace MediaBrowser.Providers.Movies } } - float rating; string voteAvg = movieData.vote_average.ToString(CultureInfo.InvariantCulture); - if (float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rating)) + if (float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var rating)) { movie.CommunityRating = rating; } @@ -195,10 +194,8 @@ namespace MediaBrowser.Providers.Movies if (!string.IsNullOrWhiteSpace(movieData.release_date)) { - DateTime r; - // These dates are always in this exact format - if (DateTime.TryParse(movieData.release_date, _usCulture, DateTimeStyles.None, out r)) + if (DateTime.TryParse(movieData.release_date, _usCulture, DateTimeStyles.None, out var r)) { movie.PremiereDate = r.ToUniversalTime(); movie.ProductionYear = movie.PremiereDate.Value.Year; diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index 88d9a346b..a1ad57ea5 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -86,10 +86,8 @@ namespace MediaBrowser.Providers.Movies if (!string.IsNullOrWhiteSpace(obj.release_date)) { - DateTime r; - // These dates are always in this exact format - if (DateTime.TryParse(obj.release_date, _usCulture, DateTimeStyles.None, out r)) + if (DateTime.TryParse(obj.release_date, _usCulture, DateTimeStyles.None, out var r)) { remoteResult.PremiereDate = r.ToUniversalTime(); remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year; diff --git a/MediaBrowser.Providers/Movies/MovieDbSearch.cs b/MediaBrowser.Providers/Movies/MovieDbSearch.cs index 95f1935a3..47d3d21bd 100644 --- a/MediaBrowser.Providers/Movies/MovieDbSearch.cs +++ b/MediaBrowser.Providers/Movies/MovieDbSearch.cs @@ -180,10 +180,8 @@ namespace MediaBrowser.Providers.Movies if (!string.IsNullOrWhiteSpace(i.release_date)) { - DateTime r; - // These dates are always in this exact format - if (DateTime.TryParseExact(i.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r)) + if (DateTime.TryParseExact(i.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out var r)) { remoteResult.PremiereDate = r.ToUniversalTime(); remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year; @@ -235,10 +233,8 @@ namespace MediaBrowser.Providers.Movies if (!string.IsNullOrWhiteSpace(i.first_air_date)) { - DateTime r; - // These dates are always in this exact format - if (DateTime.TryParseExact(i.first_air_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r)) + if (DateTime.TryParseExact(i.first_air_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out var r)) { remoteResult.PremiereDate = r.ToUniversalTime(); remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year; diff --git a/MediaBrowser.Providers/Music/Extensions.cs b/MediaBrowser.Providers/Music/Extensions.cs index 4753e8ea4..68020b9de 100644 --- a/MediaBrowser.Providers/Music/Extensions.cs +++ b/MediaBrowser.Providers/Music/Extensions.cs @@ -47,8 +47,7 @@ namespace MediaBrowser.Providers.Music public static string GetMusicBrainzArtistId(this AlbumInfo info) { - string id; - info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzAlbumArtist.ToString(), out id); + info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzAlbumArtist.ToString(), out var id); if (string.IsNullOrEmpty(id)) { @@ -66,8 +65,7 @@ namespace MediaBrowser.Providers.Music public static string GetMusicBrainzArtistId(this ArtistInfo info) { - string id; - info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzArtist.ToString(), out id); + info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzArtist.ToString(), out var id); if (string.IsNullOrEmpty(id)) { diff --git a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs index 09c11899b..3a87c2778 100644 --- a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs @@ -163,7 +163,6 @@ namespace MediaBrowser.Providers.Music if (!string.IsNullOrEmpty(url)) { var likesString = i.likes; - int likes; var info = new RemoteImageInfo { @@ -176,7 +175,7 @@ namespace MediaBrowser.Providers.Music Language = i.lang }; - if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out likes)) + if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out var likes)) { info.CommunityRating = likes; } diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs index 9d63484a8..a7456bdc0 100644 --- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs @@ -161,7 +161,6 @@ namespace MediaBrowser.Providers.Music if (!string.IsNullOrEmpty(url)) { var likesString = i.likes; - int likes; var info = new RemoteImageInfo { @@ -174,7 +173,7 @@ namespace MediaBrowser.Providers.Music Language = i.lang }; - if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out likes)) + if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out var likes)) { info.CommunityRating = likes; } diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs index 3c54b2d2f..3ad968449 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs @@ -413,8 +413,7 @@ namespace MediaBrowser.Providers.Music case "date": { var val = reader.ReadElementContentAsString(); - DateTime date; - if (DateTime.TryParse(val, out date)) + if (DateTime.TryParse(val, out var date)) { result.Year = date.Year; } diff --git a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs index 5dab978c0..646d0a5be 100644 --- a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs @@ -161,16 +161,14 @@ namespace MediaBrowser.Providers.Omdb item.SetProviderId(MetadataProviders.Imdb, result.imdbID); - int parsedYear; if (result.Year.Length > 0 - && int.TryParse(result.Year.Substring(0, Math.Min(result.Year.Length, 4)), NumberStyles.Integer, CultureInfo.InvariantCulture, out parsedYear)) + && int.TryParse(result.Year.Substring(0, Math.Min(result.Year.Length, 4)), NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedYear)) { item.ProductionYear = parsedYear; } - DateTime released; if (!string.IsNullOrEmpty(result.Released) - && DateTime.TryParse(result.Released, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out released)) + && DateTime.TryParse(result.Released, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out var released)) { item.PremiereDate = released; } diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index 618e5eb2d..44e4202bf 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -58,10 +58,8 @@ namespace MediaBrowser.Providers.Omdb } } - int year; - if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4 - && int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out year) + && int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out var year) && year >= 0) { item.ProductionYear = year; @@ -74,19 +72,15 @@ namespace MediaBrowser.Providers.Omdb item.CriticRating = tomatoScore; } - int voteCount; - if (!string.IsNullOrEmpty(result.imdbVotes) - && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount) + && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out var voteCount) && voteCount >= 0) { //item.VoteCount = voteCount; } - float imdbRating; - if (!string.IsNullOrEmpty(result.imdbRating) - && float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating) + && float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out var imdbRating) && imdbRating >= 0) { item.CommunityRating = imdbRating; @@ -165,10 +159,8 @@ namespace MediaBrowser.Providers.Omdb } } - int year; - if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4 - && int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out year) + && int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out var year) && year >= 0) { item.ProductionYear = year; @@ -181,19 +173,15 @@ namespace MediaBrowser.Providers.Omdb item.CriticRating = tomatoScore; } - int voteCount; - if (!string.IsNullOrEmpty(result.imdbVotes) - && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount) + && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out var voteCount) && voteCount >= 0) { //item.VoteCount = voteCount; } - float imdbRating; - if (!string.IsNullOrEmpty(result.imdbRating) - && float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating) + && float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out var imdbRating) && imdbRating >= 0) { item.CommunityRating = imdbRating; @@ -254,8 +242,7 @@ namespace MediaBrowser.Providers.Omdb internal static bool IsValidSeries(Dictionary seriesProviderIds) { - string id; - if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id) && !string.IsNullOrEmpty(id)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out var id) && !string.IsNullOrEmpty(id)) { // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. if (!string.IsNullOrWhiteSpace(id)) @@ -515,8 +502,7 @@ namespace MediaBrowser.Providers.Omdb if (rating != null && rating.Value != null) { var value = rating.Value.TrimEnd('%'); - float score; - if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out score)) + if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var score)) { return score; } diff --git a/MediaBrowser.Providers/People/MovieDbPersonProvider.cs b/MediaBrowser.Providers/People/MovieDbPersonProvider.cs index 9d9d8fef3..dc6ce842e 100644 --- a/MediaBrowser.Providers/People/MovieDbPersonProvider.cs +++ b/MediaBrowser.Providers/People/MovieDbPersonProvider.cs @@ -167,9 +167,7 @@ namespace MediaBrowser.Providers.People } item.Overview = info.biography; - DateTime date; - - if (DateTime.TryParseExact(info.birthday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out date)) + if (DateTime.TryParseExact(info.birthday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out var date)) { item.PremiereDate = date.ToUniversalTime(); } diff --git a/MediaBrowser.Providers/TV/FanArt/FanArtSeasonProvider.cs b/MediaBrowser.Providers/TV/FanArt/FanArtSeasonProvider.cs index 9d537f3df..493729446 100644 --- a/MediaBrowser.Providers/TV/FanArt/FanArtSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/FanArt/FanArtSeasonProvider.cs @@ -161,15 +161,12 @@ namespace MediaBrowser.Providers.TV var url = i.url; var season = i.season; - int imageSeasonNumber; - if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(season) && - int.TryParse(season, NumberStyles.Integer, _usCulture, out imageSeasonNumber) && + int.TryParse(season, NumberStyles.Integer, _usCulture, out var imageSeasonNumber) && seasonNumber == imageSeasonNumber) { var likesString = i.likes; - int likes; var info = new RemoteImageInfo { @@ -182,7 +179,7 @@ namespace MediaBrowser.Providers.TV Language = i.lang }; - if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out likes)) + if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out var likes)) { info.CommunityRating = likes; } diff --git a/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs b/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs index abdd0c7bf..7f3bc323e 100644 --- a/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs @@ -179,7 +179,6 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrEmpty(url) && isSeasonValid) { var likesString = i.likes; - int likes; var info = new RemoteImageInfo { @@ -192,7 +191,7 @@ namespace MediaBrowser.Providers.TV Language = i.lang }; - if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out likes)) + if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out var likes)) { info.CommunityRating = likes; } diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 945d9777d..8da6d4523 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -76,13 +76,9 @@ namespace MediaBrowser.Providers.TV if (parts.Length == 3) { - int seasonNumber; - - if (int.TryParse(parts[1], NumberStyles.Integer, _usCulture, out seasonNumber)) + if (int.TryParse(parts[1], NumberStyles.Integer, _usCulture, out var seasonNumber)) { - int episodeNumber; - - if (int.TryParse(parts[2], NumberStyles.Integer, _usCulture, out episodeNumber)) + if (int.TryParse(parts[2], NumberStyles.Integer, _usCulture, out var episodeNumber)) { return new ValueTuple(seasonNumber, episodeNumber); } @@ -506,8 +502,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - DateTime date; - if (DateTime.TryParse(val, out date)) + if (DateTime.TryParse(val, out var date)) { airDate = date.ToUniversalTime(); } diff --git a/MediaBrowser.Providers/TV/Omdb/OmdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/Omdb/OmdbEpisodeProvider.cs index e37e867e5..38bb83694 100644 --- a/MediaBrowser.Providers/TV/Omdb/OmdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/Omdb/OmdbEpisodeProvider.cs @@ -56,8 +56,7 @@ namespace MediaBrowser.Providers.TV return result; } - string seriesImdbId; - if (info.SeriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesImdbId) && !string.IsNullOrEmpty(seriesImdbId)) + if (info.SeriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out var seriesImdbId) && !string.IsNullOrEmpty(seriesImdbId)) { if (info.IndexNumber.HasValue && info.ParentIndexNumber.HasValue) { diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs index 49f73286d..08e541ecf 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs @@ -71,8 +71,7 @@ namespace MediaBrowser.Providers.TV return result; } - string seriesTmdbId; - info.SeriesProviderIds.TryGetValue(MetadataProviders.Tmdb.ToString(), out seriesTmdbId); + info.SeriesProviderIds.TryGetValue(MetadataProviders.Tmdb.ToString(), out var seriesTmdbId); if (string.IsNullOrEmpty(seriesTmdbId)) { diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs index a29fd46df..3a40aed7b 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs @@ -44,8 +44,7 @@ namespace MediaBrowser.Providers.TV { var result = new MetadataResult(); - string seriesTmdbId; - info.SeriesProviderIds.TryGetValue(MetadataProviders.Tmdb.ToString(), out seriesTmdbId); + info.SeriesProviderIds.TryGetValue(MetadataProviders.Tmdb.ToString(), out var seriesTmdbId); var seasonNumber = info.IndexNumber; diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs index 0844862db..2cadaec86 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs @@ -219,9 +219,8 @@ namespace MediaBrowser.Providers.TV //series.VoteCount = seriesInfo.vote_count; string voteAvg = seriesInfo.vote_average.ToString(CultureInfo.InvariantCulture); - float rating; - if (float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rating)) + if (float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var rating)) { series.CommunityRating = rating; } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs index c594cb923..39d2fa77a 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs @@ -94,10 +94,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { width = rval; } @@ -111,10 +109,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { height = rval; } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs index dc0a785ec..c4edb43ff 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs @@ -401,8 +401,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - DateTime date; - if (DateTime.TryParse(val, out date)) + if (DateTime.TryParse(val, out var date)) { date = date.ToUniversalTime(); @@ -482,10 +481,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { episodeNumber = rval; } @@ -500,10 +497,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { seasonNumber = rval; } @@ -518,9 +513,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - float num; - - if (float.TryParse(val, NumberStyles.Any, _usCulture, out num)) + if (float.TryParse(val, NumberStyles.Any, _usCulture, out var num)) { combinedEpisodeNumber = Convert.ToInt32(num); } @@ -535,9 +528,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - float num; - - if (float.TryParse(val, NumberStyles.Any, _usCulture, out num)) + if (float.TryParse(val, NumberStyles.Any, _usCulture, out var num)) { combinedSeasonNumber = Convert.ToInt32(num); } @@ -552,10 +543,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { item.AirsBeforeEpisodeNumber = rval; } @@ -570,10 +559,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { item.AirsAfterSeasonNumber = rval; } @@ -588,10 +575,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { item.AirsBeforeSeasonNumber = rval; } @@ -631,10 +616,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - float rval; - // float.TryParse is local aware, so it can be probamatic, force us culture - if (float.TryParse(val, NumberStyles.AllowDecimalPoint, _usCulture, out rval)) + if (float.TryParse(val, NumberStyles.AllowDecimalPoint, _usCulture, out var rval)) { item.CommunityRating = rval; } @@ -647,10 +630,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { //item.VoteCount = rval; } @@ -665,8 +646,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - DateTime date; - if (DateTime.TryParse(val, out date)) + if (DateTime.TryParse(val, out var date)) { date = date.ToUniversalTime(); diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs index 33fefc29c..c4a132d45 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs @@ -161,9 +161,7 @@ namespace MediaBrowser.Providers.TV newUpdateTime = seriesToUpdate.Item2; - long lastUpdateValue; - - long.TryParse(lastUpdateTime, NumberStyles.Any, UsCulture, out lastUpdateValue); + long.TryParse(lastUpdateTime, NumberStyles.Any, UsCulture, out var lastUpdateValue); var nullableUpdateValue = lastUpdateValue == 0 ? (long?)null : lastUpdateValue; diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs index 4cdfb4b11..af36d1ebf 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs @@ -201,9 +201,7 @@ namespace MediaBrowser.Providers.TV { var val = reader.ReadElementContentAsString() ?? string.Empty; - double rval; - - if (double.TryParse(val, NumberStyles.Any, UsCulture, out rval)) + if (double.TryParse(val, NumberStyles.Any, UsCulture, out var rval)) { rating = rval; } @@ -215,9 +213,7 @@ namespace MediaBrowser.Providers.TV { var val = reader.ReadElementContentAsString() ?? string.Empty; - int rval; - - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, UsCulture, out var rval)) { voteCount = rval; } @@ -252,9 +248,7 @@ namespace MediaBrowser.Providers.TV if (resolutionParts.Length == 2) { - int rval; - - if (int.TryParse(resolutionParts[0], NumberStyles.Integer, UsCulture, out rval)) + if (int.TryParse(resolutionParts[0], NumberStyles.Integer, UsCulture, out var rval)) { width = rval; } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs index 3ee1bf7dc..82fa14f49 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs @@ -197,9 +197,7 @@ namespace MediaBrowser.Providers.TV { var val = reader.ReadElementContentAsString() ?? string.Empty; - double rval; - - if (double.TryParse(val, NumberStyles.Any, _usCulture, out rval)) + if (double.TryParse(val, NumberStyles.Any, _usCulture, out var rval)) { rating = rval; } @@ -211,9 +209,7 @@ namespace MediaBrowser.Providers.TV { var val = reader.ReadElementContentAsString() ?? string.Empty; - int rval; - - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { voteCount = rval; } @@ -255,9 +251,7 @@ namespace MediaBrowser.Providers.TV if (resolutionParts.Length == 2) { - int rval; - - if (int.TryParse(resolutionParts[0], NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(resolutionParts[0], NumberStyles.Integer, _usCulture, out var rval)) { width = rval; } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index 958312633..f55c52b5b 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -137,8 +137,7 @@ namespace MediaBrowser.Providers.TV { var series = result.Item; - string id; - if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id) && !string.IsNullOrEmpty(id)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out var id) && !string.IsNullOrEmpty(id)) { series.SetProviderId(MetadataProviders.Tvdb, id); } @@ -389,8 +388,7 @@ namespace MediaBrowser.Providers.TV internal static bool IsValidSeries(Dictionary seriesProviderIds) { - string id; - if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out var id)) { // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. if (!string.IsNullOrWhiteSpace(id)) @@ -426,8 +424,7 @@ namespace MediaBrowser.Providers.TV try { - string seriesId; - if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId) && !string.IsNullOrWhiteSpace(seriesId)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out var seriesId) && !string.IsNullOrWhiteSpace(seriesId)) { var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); @@ -721,8 +718,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - DateTime date; - if (DateTime.TryParse(val, out date)) + if (DateTime.TryParse(val, out var date)) { searchResult.ProductionYear = date.Year; } @@ -926,8 +922,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - DateTime date; - if (DateTime.TryParse(val, out date)) + if (DateTime.TryParse(val, out var date)) { airDate = date.ToUniversalTime(); } @@ -942,10 +937,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { seasonNumber = rval; } @@ -1086,10 +1079,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { personInfo.SortOrder = rval; } @@ -1195,10 +1186,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - float rval; - // float.TryParse is local aware, so it can be probamatic, force us culture - if (float.TryParse(val, NumberStyles.AllowDecimalPoint, _usCulture, out rval)) + if (float.TryParse(val, NumberStyles.AllowDecimalPoint, _usCulture, out var rval)) { item.CommunityRating = rval; } @@ -1211,10 +1200,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { //item.VoteCount = rval; } @@ -1253,9 +1240,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - SeriesStatus seriesStatus; - - if (Enum.TryParse(val, true, out seriesStatus)) + if (Enum.TryParse(val, true, out SeriesStatus seriesStatus)) item.Status = seriesStatus; } @@ -1268,8 +1253,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - DateTime date; - if (DateTime.TryParse(val, out date)) + if (DateTime.TryParse(val, out var date)) { date = date.ToUniversalTime(); @@ -1287,10 +1271,8 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var rval)) { item.RunTimeTicks = TimeSpan.FromMinutes(rval).Ticks; } @@ -1455,8 +1437,7 @@ namespace MediaBrowser.Providers.TV var val = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(val)) { - int num; - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out num)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var num)) { episodeNumber = num; } @@ -1470,9 +1451,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - float num; - - if (float.TryParse(val, NumberStyles.Any, _usCulture, out num)) + if (float.TryParse(val, NumberStyles.Any, _usCulture, out var num)) { dvdEpisodeNumber = num; } @@ -1487,9 +1466,7 @@ namespace MediaBrowser.Providers.TV if (!string.IsNullOrWhiteSpace(val)) { - float num; - - if (float.TryParse(val, NumberStyles.Any, _usCulture, out num)) + if (float.TryParse(val, NumberStyles.Any, _usCulture, out var num)) { dvdSeasonNumber = Convert.ToInt32(num); } @@ -1503,8 +1480,7 @@ namespace MediaBrowser.Providers.TV var val = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(val)) { - int num; - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out num)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var num)) { absoluteNumber = num; } @@ -1517,8 +1493,7 @@ namespace MediaBrowser.Providers.TV var val = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(val)) { - int num; - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out num)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var num)) { seasonNumber = num; } @@ -1542,8 +1517,7 @@ namespace MediaBrowser.Providers.TV var hasEpisodeChanged = true; if (!string.IsNullOrWhiteSpace(lastUpdateString) && lastTvDbUpdateTime.HasValue) { - long num; - if (long.TryParse(lastUpdateString, NumberStyles.Any, _usCulture, out num)) + if (long.TryParse(lastUpdateString, NumberStyles.Any, _usCulture, out var num)) { hasEpisodeChanged = num >= lastTvDbUpdateTime.Value; } @@ -1618,8 +1592,7 @@ namespace MediaBrowser.Providers.TV /// System.String. internal static string GetSeriesDataPath(IApplicationPaths appPaths, Dictionary seriesProviderIds) { - string seriesId; - if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out var seriesId) && !string.IsNullOrEmpty(seriesId)) { var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId); diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 3744df9b4..47cad3e1b 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -239,8 +239,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (index != -1) { var tmdbId = xml.Substring(index + srch.Length).TrimEnd('/').Split('-')[0]; - int value; - if (!string.IsNullOrWhiteSpace(tmdbId) && int.TryParse(tmdbId, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) + if (!string.IsNullOrWhiteSpace(tmdbId) && int.TryParse(tmdbId, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value)) { item.SetProviderId(MetadataProviders.Tmdb, value.ToString(_usCulture)); } @@ -255,8 +254,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (index != -1) { var tvdbId = xml.Substring(index + srch.Length).TrimEnd('/'); - int value; - if (!string.IsNullOrWhiteSpace(tvdbId) && int.TryParse(tvdbId, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) + if (!string.IsNullOrWhiteSpace(tvdbId) && int.TryParse(tvdbId, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value)) { item.SetProviderId(MetadataProviders.Tvdb, value.ToString(_usCulture)); } @@ -277,8 +275,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - DateTime added; - if (DateTime.TryParseExact(val, BaseNfoSaver.DateAddedFormat, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out added)) + if (DateTime.TryParseExact(val, BaseNfoSaver.DateAddedFormat, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var added)) { item.DateCreated = added.ToUniversalTime(); } @@ -316,8 +313,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrEmpty(text)) { - float value; - if (float.TryParse(text, NumberStyles.Any, _usCulture, out value)) + if (float.TryParse(text, NumberStyles.Any, _usCulture, out var value)) { item.CriticRating = value; } @@ -377,9 +373,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers { item.LockedFields = val.Split('|').Select(i => { - MetadataFields field; - - if (Enum.TryParse(i, true, out field)) + if (Enum.TryParse(i, true, out MetadataFields field)) { return (MetadataFields?)field; } @@ -445,8 +439,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(text)) { - int runtime; - if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out runtime)) + if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out var runtime)) { item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks; } @@ -599,8 +592,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int productionYear; - if (int.TryParse(val, out productionYear) && productionYear > 1850) + if (int.TryParse(val, out var productionYear) && productionYear > 1850) { item.ProductionYear = productionYear; } @@ -616,9 +608,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(rating)) { - float val; // All external meta is saving this as '.' for decimal I believe...but just to be sure - if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out val)) + if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var val)) { item.CommunityRating = val; } @@ -637,9 +628,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - DateTime date; - - if (DateTime.TryParseExact(val, formatString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out date) && date.Year > 1850) + if (DateTime.TryParseExact(val, formatString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var date) && date.Year > 1850) { item.PremiereDate = date.ToUniversalTime(); item.ProductionYear = date.Year; @@ -657,9 +646,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - DateTime date; - - if (DateTime.TryParseExact(val, formatString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out date) && date.Year > 1850) + if (DateTime.TryParseExact(val, formatString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var date) && date.Year > 1850) { item.EndDate = date.ToUniversalTime(); } @@ -715,8 +702,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers default: string readerName = reader.Name; - string providerIdValue; - if (_validProviderIds.TryGetValue(readerName, out providerIdValue)) + if (_validProviderIds.TryGetValue(readerName, out var providerIdValue)) { var id = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(id)) @@ -906,8 +892,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int intVal; - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out intVal)) + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var intVal)) { sortOrder = intVal; } diff --git a/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs index 5ba695cc3..c76f8345a 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs @@ -97,9 +97,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(number)) { - int num; - - if (int.TryParse(number, out num)) + if (int.TryParse(number, out var num)) { item.ParentIndexNumber = num; } @@ -113,9 +111,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(number)) { - int num; - - if (int.TryParse(number, out num)) + if (int.TryParse(number, out var num)) { item.IndexNumber = num; } @@ -129,9 +125,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(number)) { - int num; - - if (int.TryParse(number, out num)) + if (int.TryParse(number, out var num)) { item.IndexNumberEnd = num; } @@ -145,10 +139,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, UsCulture, out var rval)) { item.AirsBeforeEpisodeNumber = rval; } @@ -163,10 +155,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, UsCulture, out var rval)) { item.AirsAfterSeasonNumber = rval; } @@ -181,10 +171,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, UsCulture, out var rval)) { item.AirsBeforeSeasonNumber = rval; } @@ -199,10 +187,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, UsCulture, out var rval)) { item.AirsBeforeSeasonNumber = rval; } @@ -217,10 +203,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - int rval; - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) + if (int.TryParse(val, NumberStyles.Integer, UsCulture, out var rval)) { item.AirsBeforeEpisodeNumber = rval; } diff --git a/MediaBrowser.XbmcMetadata/Parsers/SeasonNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/SeasonNfoParser.cs index 57aea88a3..17f36d82d 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/SeasonNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/SeasonNfoParser.cs @@ -28,9 +28,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(number)) { - int num; - - if (int.TryParse(number, NumberStyles.Integer, CultureInfo.InvariantCulture, out num)) + if (int.TryParse(number, NumberStyles.Integer, CultureInfo.InvariantCulture, out var num)) { item.IndexNumber = num; } diff --git a/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs index 571fc5035..700656b65 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs @@ -75,8 +75,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(status)) { - SeriesStatus seriesStatus; - if (Enum.TryParse(status, true, out seriesStatus)) + if (Enum.TryParse(status, true, out SeriesStatus seriesStatus)) { item.Status = seriesStatus; } diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index 1251d19c0..b9894ca8f 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -932,9 +932,8 @@ namespace SocketHttpListener /// public static Uri ToUri(this string uriString) { - Uri res; return Uri.TryCreate( - uriString, uriString.MaybeUri() ? UriKind.Absolute : UriKind.Relative, out res) + uriString, uriString.MaybeUri() ? UriKind.Absolute : UriKind.Relative, out var res) ? res : null; } diff --git a/SocketHttpListener/Net/CookieHelper.cs b/SocketHttpListener/Net/CookieHelper.cs index c59756c77..3ad76ff23 100644 --- a/SocketHttpListener/Net/CookieHelper.cs +++ b/SocketHttpListener/Net/CookieHelper.cs @@ -43,13 +43,12 @@ namespace SocketHttpListener.Net if (i < pairs.Length - 1) buffer.AppendFormat(", {0}", pairs[++i].Trim()); - DateTime expires; if (!DateTime.TryParseExact( buffer.ToString(), new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, new CultureInfo("en-US"), DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, - out expires)) + out var expires)) expires = DateTime.Now; if (cookie != null && cookie.Expires == DateTime.MinValue) diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs index d002c13b2..c78d186c5 100644 --- a/SocketHttpListener/Net/HttpEndPointListener.cs +++ b/SocketHttpListener/Net/HttpEndPointListener.cs @@ -277,8 +277,7 @@ namespace SocketHttpListener.Net public bool BindContext(HttpListenerContext context) { var req = context.Request; - ListenerPrefix prefix; - var listener = SearchListener(req.Url, out prefix); + var listener = SearchListener(req.Url, out var prefix); if (listener == null) return false; diff --git a/SocketHttpListener/Net/HttpEndPointManager.cs b/SocketHttpListener/Net/HttpEndPointManager.cs index 98986333b..07b6331f2 100644 --- a/SocketHttpListener/Net/HttpEndPointManager.cs +++ b/SocketHttpListener/Net/HttpEndPointManager.cs @@ -57,8 +57,7 @@ namespace SocketHttpListener.Net int root = p.IndexOf('/', colon, p.Length - colon); string portString = p.Substring(colon + 1, root - colon - 1); - int port; - if (!int.TryParse(portString, out port) || port <= 0 || port >= 65536) + if (!int.TryParse(portString, out var port) || port <= 0 || port >= 65536) { throw new HttpListenerException((int)HttpStatusCode.BadRequest, "net_invalid_port"); } diff --git a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs index 310c71a0d..52e70b68b 100644 --- a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs +++ b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs @@ -232,8 +232,7 @@ namespace SocketHttpListener.Net { // http.sys only supports %uXXXX (4 hex-digits), even though unicode code points could have up to // 6 hex digits. Therefore we parse always 4 characters after %u and convert them to an int. - int codePointValue; - if (!int.TryParse(codePoint, NumberStyles.HexNumber, null, out codePointValue)) + if (!int.TryParse(codePoint, NumberStyles.HexNumber, null, out var codePointValue)) { //if (NetEventSource.IsEnabled) // NetEventSource.Error(this, SR.Format(SR.net_log_listener_cant_convert_percent_value, codePoint)); @@ -264,8 +263,7 @@ namespace SocketHttpListener.Net private bool AddPercentEncodedOctetToRawOctetsList(Encoding encoding, string escapedCharacter) { - byte encodedValue; - if (!byte.TryParse(escapedCharacter, NumberStyles.HexNumber, null, out encodedValue)) + if (!byte.TryParse(escapedCharacter, NumberStyles.HexNumber, null, out var encodedValue)) { //if (NetEventSource.IsEnabled) NetEventSource.Error(this, SR.Format(SR.net_log_listener_cant_convert_percent_value, escapedCharacter)); return false; diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs index 02d3cf61f..c56d2ef38 100644 --- a/SocketHttpListener/Net/WebHeaderCollection.cs +++ b/SocketHttpListener/Net/WebHeaderCollection.cs @@ -208,8 +208,7 @@ namespace SocketHttpListener.Net if (!IsHeaderName(headerName)) throw new ArgumentException("Invalid character in header"); - HeaderInfo info; - if (!headers.TryGetValue(headerName, out info)) + if (!headers.TryGetValue(headerName, out var info)) return false; var flag = response ? HeaderInfo.Response : HeaderInfo.Request; @@ -313,8 +312,7 @@ namespace SocketHttpListener.Net if (headerName == null) return false; - HeaderInfo info; - return headers.TryGetValue(headerName, out info) && (info & HeaderInfo.MultiValue) != 0; + return headers.TryGetValue(headerName, out var info) && (info & HeaderInfo.MultiValue) != 0; } internal static bool IsHeaderValue(string value) diff --git a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs index f51f72dba..5f77ff565 100644 --- a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs +++ b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs @@ -26,12 +26,11 @@ namespace SocketHttpListener.Net.WebSockets string origin = request.Headers[HttpKnownHeaderNames.Origin]; string[] secWebSocketProtocols = null; - string outgoingSecWebSocketProtocolString; bool shouldSendSecWebSocketProtocolHeader = ProcessWebSocketProtocolHeader( request.Headers[HttpKnownHeaderNames.SecWebSocketProtocol], subProtocol, - out outgoingSecWebSocketProtocolString); + out var outgoingSecWebSocketProtocolString); if (shouldSendSecWebSocketProtocolHeader) { -- cgit v1.2.3 From c1f76eb8ab2c4fe536a9b612d659bf739f0cc7ac Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Fri, 18 Jan 2019 16:48:01 +0100 Subject: Reformat JustAMan review pt3 changes --- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 2 +- Mono.Nat/NatProtocol.cs | 1 - Mono.Nat/Pmp/PmpSearcher.cs | 10 +- .../Messages/Requests/CreatePortMappingMessage.cs | 2 +- Mono.Nat/Upnp/UpnpNatDevice.cs | 2 +- OpenSubtitlesHandler/OpenSubtitles.cs | 136 ++++++++++----------- OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs | 14 +-- SocketHttpListener/Ext.cs | 2 +- SocketHttpListener/Net/ChunkedInputStream.cs | 4 +- SocketHttpListener/Net/HttpConnection.cs | 6 +- SocketHttpListener/Net/HttpEndPointListener.cs | 16 +-- SocketHttpListener/Net/HttpEndPointManager.cs | 4 +- .../Net/HttpListenerContext.Managed.cs | 2 +- .../Net/HttpListenerRequest.Managed.cs | 4 +- .../Net/HttpListenerRequestUriBuilder.cs | 8 +- .../Net/HttpResponseStream.Managed.cs | 10 +- SocketHttpListener/Net/WebHeaderCollection.cs | 4 +- .../Net/WebSockets/HttpWebSocket.Managed.cs | 4 +- .../Net/WebSockets/WebSocketValidate.cs | 2 +- SocketHttpListener/WebSocket.cs | 1 + 20 files changed, 117 insertions(+), 117 deletions(-) (limited to 'SocketHttpListener/Ext.cs') diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 47cad3e1b..513296745 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -702,7 +702,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers default: string readerName = reader.Name; - if (_validProviderIds.TryGetValue(readerName, out var providerIdValue)) + if (_validProviderIds.TryGetValue(readerName, out string providerIdValue)) { var id = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(id)) diff --git a/Mono.Nat/NatProtocol.cs b/Mono.Nat/NatProtocol.cs index a796f9483..2768f133c 100644 --- a/Mono.Nat/NatProtocol.cs +++ b/Mono.Nat/NatProtocol.cs @@ -1,4 +1,3 @@ - namespace Mono.Nat { public enum NatProtocol diff --git a/Mono.Nat/Pmp/PmpSearcher.cs b/Mono.Nat/Pmp/PmpSearcher.cs index cbd0d3686..46c2e9d80 100644 --- a/Mono.Nat/Pmp/PmpSearcher.cs +++ b/Mono.Nat/Pmp/PmpSearcher.cs @@ -85,10 +85,10 @@ namespace Mono.Nat { if (n.OperationalStatus != OperationalStatus.Up && n.OperationalStatus != OperationalStatus.Unknown) continue; - var properties = n.GetIPProperties(); + IPInterfaceProperties properties = n.GetIPProperties(); var gatewayList = new List(); - foreach (var gateway in properties.GatewayAddresses) + foreach (GatewayIPAddressInformation gateway in properties.GatewayAddresses) { if (gateway.Address.AddressFamily == AddressFamily.InterNetwork) { @@ -105,7 +105,7 @@ namespace Mono.Nat gatewayList.Add(new IPEndPoint(gw2, PmpConstants.ServerPort)); } } - foreach (var unicast in properties.UnicastAddresses) + foreach (UnicastIPAddressInformation unicast in properties.UnicastAddresses) { if (/*unicast.DuplicateAddressDetectionState == DuplicateAddressDetectionState.Preferred && unicast.AddressPreferredLifetime != UInt32.MaxValue @@ -150,7 +150,7 @@ namespace Mono.Nat public async void Search() { - foreach (var s in sockets) + foreach (UdpClient s in sockets) { try { @@ -181,7 +181,7 @@ namespace Mono.Nat // The nat-pmp search message. Must be sent to GatewayIP:53531 byte[] buffer = new byte[] { PmpConstants.Version, PmpConstants.OperationCode }; - foreach (var gatewayEndpoint in gatewayLists[client]) + foreach (IPEndPoint gatewayEndpoint in gatewayLists[client]) { await client.SendAsync(buffer, buffer.Length, gatewayEndpoint).ConfigureAwait(false); } diff --git a/Mono.Nat/Upnp/Messages/Requests/CreatePortMappingMessage.cs b/Mono.Nat/Upnp/Messages/Requests/CreatePortMappingMessage.cs index 217095e49..7d6844e32 100644 --- a/Mono.Nat/Upnp/Messages/Requests/CreatePortMappingMessage.cs +++ b/Mono.Nat/Upnp/Messages/Requests/CreatePortMappingMessage.cs @@ -57,7 +57,7 @@ namespace Mono.Nat.Upnp var culture = CultureInfo.InvariantCulture; var builder = new StringBuilder(256); - var writer = CreateWriter(builder); + XmlWriter writer = CreateWriter(builder); WriteFullElement(writer, "NewRemoteHost", string.Empty); WriteFullElement(writer, "NewExternalPort", this.mapping.PublicPort.ToString(culture)); diff --git a/Mono.Nat/Upnp/UpnpNatDevice.cs b/Mono.Nat/Upnp/UpnpNatDevice.cs index 63a28ebdc..fd408ee63 100644 --- a/Mono.Nat/Upnp/UpnpNatDevice.cs +++ b/Mono.Nat/Upnp/UpnpNatDevice.cs @@ -146,7 +146,7 @@ namespace Mono.Nat.Upnp var ns = new XmlNamespaceManager(xmldoc.NameTable); ns.AddNamespace("ns", "urn:schemas-upnp-org:device-1-0"); - var nodes = xmldoc.SelectNodes("//*/ns:serviceList", ns); + XmlNodeList nodes = xmldoc.SelectNodes("//*/ns:serviceList", ns); foreach (XmlNode node in nodes) { diff --git a/OpenSubtitlesHandler/OpenSubtitles.cs b/OpenSubtitlesHandler/OpenSubtitles.cs index ddf2e83e8..76f70dc07 100644 --- a/OpenSubtitlesHandler/OpenSubtitles.cs +++ b/OpenSubtitlesHandler/OpenSubtitles.cs @@ -79,7 +79,7 @@ namespace OpenSubtitlesHandler { var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; var re = new MethodResponseLogIn("Success", "Log in successful."); - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -128,7 +128,7 @@ namespace OpenSubtitlesHandler { var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; var re = new MethodResponseLogIn("Success", "Log in successful."); - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -233,7 +233,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseNoOperation(); var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -241,7 +241,7 @@ namespace OpenSubtitlesHandler case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data); break; case "download_limits": var dlStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (var dlmember in dlStruct.Members) + foreach (XmlRpcStructMember dlmember in dlStruct.Members) { OSHConsole.WriteLine(" >" + dlmember.Name + "= " + dlmember.Data.Data.ToString()); switch (dlmember.Name) @@ -297,7 +297,7 @@ namespace OpenSubtitlesHandler parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Add subtitle search parameters. Each one will be like 'array' of structs. var array = new XmlRpcValueArray(); - foreach (var param in parameters) + foreach (SubtitleSearchParameters param in parameters) { var strct = new XmlRpcValueStruct(new List()); // sublanguageid member @@ -366,7 +366,7 @@ namespace OpenSubtitlesHandler // Create the response, we'll need it later var R = new MethodResponseSubtitleSearch(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -385,13 +385,13 @@ namespace OpenSubtitlesHandler OSHConsole.WriteLine("Search results: "); var rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (var subStruct in rarray.Values) + foreach (IXmlRpcValue subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; var result = new SubtitleSearchResult(); - foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) + foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -477,7 +477,7 @@ namespace OpenSubtitlesHandler parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); // Add subtitle search parameters. Each one will be like 'array' of structs. var array = new XmlRpcValueArray(); - foreach (var param in parameters) + foreach (SubtitleSearchParameters param in parameters) { var strct = new XmlRpcValueStruct(new List()); // sublanguageid member @@ -546,7 +546,7 @@ namespace OpenSubtitlesHandler // Create the response, we'll need it later var R = new MethodResponseSubtitleSearch(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -565,13 +565,13 @@ namespace OpenSubtitlesHandler OSHConsole.WriteLine("Search results: "); var rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (var subStruct in rarray.Values) + foreach (IXmlRpcValue subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; var result = new SubtitleSearchResult(); - foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) + foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -690,7 +690,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseSubtitleDownload(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -708,13 +708,13 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine("Download results:"); var rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (var subStruct in rarray.Values) + foreach (IXmlRpcValue subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; var result = new SubtitleDownloadResult(); - foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) + foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -800,7 +800,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseSubtitleDownload(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -818,13 +818,13 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine("Download results:"); var rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (var subStruct in rarray.Values) + foreach (IXmlRpcValue subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; var result = new SubtitleDownloadResult(); - foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) + foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -904,7 +904,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseGetComments(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -922,13 +922,13 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine("Comments results:"); var rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (var commentStruct in rarray.Values) + foreach (IXmlRpcValue commentStruct in rarray.Values) { if (commentStruct == null) continue; if (!(commentStruct is XmlRpcValueStruct)) continue; var result = new GetCommentsResult(); - foreach (var commentmember in ((XmlRpcValueStruct)commentStruct).Members) + foreach (XmlRpcStructMember commentmember in ((XmlRpcValueStruct)commentStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (commentmember.Name) @@ -984,7 +984,7 @@ namespace OpenSubtitlesHandler parms.Add(a); // Array of video parameters a = new XmlRpcValueArray(); - foreach (var p in movies) + foreach (SearchToMailMovieParameter p in movies) { var str = new XmlRpcValueStruct(new List()); str.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash))); @@ -1010,7 +1010,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseSearchToMail(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1067,7 +1067,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseMovieSearch(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -1085,13 +1085,13 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine("Search results:"); var rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (var subStruct in rarray.Values) + foreach (IXmlRpcValue subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; var result = new MovieSearchResult(); - foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) + foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -1158,7 +1158,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseMovieDetails(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -1177,7 +1177,7 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine("Details result:"); var detailsStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (var dmem in detailsStruct.Members) + foreach (XmlRpcStructMember dmem in detailsStruct.Members) { switch (dmem.Name) { @@ -1194,7 +1194,7 @@ namespace OpenSubtitlesHandler // this is another struct with cast members... OSHConsole.WriteLine(">" + dmem.Name + "= "); var castStruct = (XmlRpcValueStruct)dmem.Data; - foreach (var castMemeber in castStruct.Members) + foreach (XmlRpcStructMember castMemeber in castStruct.Members) { R.Cast.Add(castMemeber.Data.Data.ToString()); OSHConsole.WriteLine(" >" + castMemeber.Data.Data.ToString()); @@ -1204,7 +1204,7 @@ namespace OpenSubtitlesHandler OSHConsole.WriteLine(">" + dmem.Name + "= "); // this is another struct with directors members... var directorsStruct = (XmlRpcValueStruct)dmem.Data; - foreach (var directorsMember in directorsStruct.Members) + foreach (XmlRpcStructMember directorsMember in directorsStruct.Members) { R.Directors.Add(directorsMember.Data.Data.ToString()); OSHConsole.WriteLine(" >" + directorsMember.Data.Data.ToString()); @@ -1214,7 +1214,7 @@ namespace OpenSubtitlesHandler OSHConsole.WriteLine(">" + dmem.Name + "= "); // this is another struct with writers members... var writersStruct = (XmlRpcValueStruct)dmem.Data; - foreach (var writersMember in writersStruct.Members) + foreach (XmlRpcStructMember writersMember in writersStruct.Members) { R.Writers.Add(writersMember.Data.Data.ToString()); OSHConsole.WriteLine("+->" + writersMember.Data.Data.ToString()); @@ -1330,7 +1330,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseInsertMovie(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { if (MEMBER.Name == "status") { @@ -1375,7 +1375,7 @@ namespace OpenSubtitlesHandler // Method call .. var parms = new List(); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); - foreach (var p in parameters) + foreach (InsertMovieHashParameters p in parameters) { var pstruct = new XmlRpcValueStruct(new List()); pstruct.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash))); @@ -1404,7 +1404,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseInsertMovieHash(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1418,13 +1418,13 @@ namespace OpenSubtitlesHandler break; case "data": var dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (var dataMember in dataStruct.Members) + foreach (XmlRpcStructMember dataMember in dataStruct.Members) { switch (dataMember.Name) { case "accepted_moviehashes": var mh = (XmlRpcValueArray)dataMember.Data; - foreach (var val in mh.Values) + foreach (IXmlRpcValue val in mh.Values) { if (val is XmlRpcValueBasic) { @@ -1434,7 +1434,7 @@ namespace OpenSubtitlesHandler break; case "new_imdbs": var mi = (XmlRpcValueArray)dataMember.Data; - foreach (var val in mi.Values) + foreach (IXmlRpcValue val in mi.Values) { if (val is XmlRpcValueBasic) { @@ -1493,7 +1493,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseServerInfo(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1569,7 +1569,7 @@ namespace OpenSubtitlesHandler //R.total_subtitles_languages = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + ":"); var luStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (var luMemeber in luStruct.Members) + foreach (XmlRpcStructMember luMemeber in luStruct.Members) { R.last_update_strings.Add(luMemeber.Name + " [" + luMemeber.Data.Data.ToString() + "]"); OSHConsole.WriteLine(" >" + luMemeber.Name + "= " + luMemeber.Data.Data.ToString()); @@ -1623,7 +1623,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseReportWrongMovieHash(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1691,7 +1691,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseAddComment(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1749,7 +1749,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseSubtitlesVote(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1757,7 +1757,7 @@ namespace OpenSubtitlesHandler case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": var dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (var dataMemeber in dataStruct.Members) + foreach (XmlRpcStructMember dataMemeber in dataStruct.Members) { OSHConsole.WriteLine(" >" + dataMemeber.Name + "= " + dataMemeber.Data.Data.ToString()); switch (dataMemeber.Name) @@ -1882,7 +1882,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseAddRequest(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1890,7 +1890,7 @@ namespace OpenSubtitlesHandler case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data": var dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (var dataMemeber in dataStruct.Members) + foreach (XmlRpcStructMember dataMemeber in dataStruct.Members) { switch (dataMemeber.Name) { @@ -1947,7 +1947,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseGetSubLanguages(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -1955,14 +1955,14 @@ namespace OpenSubtitlesHandler case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "data":// array of structs var array = (XmlRpcValueArray)MEMBER.Data; - foreach (var value in array.Values) + foreach (IXmlRpcValue value in array.Values) { if (value is XmlRpcValueStruct) { var valueStruct = (XmlRpcValueStruct)value; var lang = new SubtitleLanguage(); OSHConsole.WriteLine(">SubLanguage:"); - foreach (var langMemeber in valueStruct.Members) + foreach (XmlRpcStructMember langMemeber in valueStruct.Members) { OSHConsole.WriteLine(" >" + langMemeber.Name + "= " + langMemeber.Data.Data.ToString()); switch (langMemeber.Name) @@ -2043,7 +2043,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseDetectLanguage(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2054,7 +2054,7 @@ namespace OpenSubtitlesHandler { OSHConsole.WriteLine(">Languages:"); var dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (var dataMember in dataStruct.Members) + foreach (XmlRpcStructMember dataMember in dataStruct.Members) { var lang = new DetectLanguageResult(); lang.InputSample = dataMember.Name; @@ -2116,7 +2116,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseGetAvailableTranslations(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2125,7 +2125,7 @@ namespace OpenSubtitlesHandler case "data": var dataStruct = (XmlRpcValueStruct)MEMBER.Data; OSHConsole.WriteLine(">data:"); - foreach (var dataMember in dataStruct.Members) + foreach (XmlRpcStructMember dataMember in dataStruct.Members) { if (dataMember.Data is XmlRpcValueStruct) { @@ -2133,7 +2133,7 @@ namespace OpenSubtitlesHandler var res = new GetAvailableTranslationsResult(); res.LanguageID = dataMember.Name; OSHConsole.WriteLine(" >LanguageID: " + dataMember.Name); - foreach (var resMember in resStruct.Members) + foreach (XmlRpcStructMember resMember in resStruct.Members) { switch (resMember.Name) { @@ -2202,7 +2202,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseGetTranslation(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2258,7 +2258,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseAutoUpdate(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2317,7 +2317,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseCheckMovieHash(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2326,13 +2326,13 @@ namespace OpenSubtitlesHandler case "data": var dataStruct = (XmlRpcValueStruct)MEMBER.Data; OSHConsole.WriteLine(">Data:"); - foreach (var dataMember in dataStruct.Members) + foreach (XmlRpcStructMember dataMember in dataStruct.Members) { var res = new CheckMovieHashResult(); res.Name = dataMember.Name; OSHConsole.WriteLine(" >" + res.Name + ":"); var movieStruct = (XmlRpcValueStruct)dataMember.Data; - foreach (var movieMember in movieStruct.Members) + foreach (XmlRpcStructMember movieMember in movieStruct.Members) { switch (movieMember.Name) { @@ -2394,7 +2394,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseCheckMovieHash2(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2403,7 +2403,7 @@ namespace OpenSubtitlesHandler case "data": var dataStruct = (XmlRpcValueStruct)MEMBER.Data; OSHConsole.WriteLine(">Data:"); - foreach (var dataMember in dataStruct.Members) + foreach (XmlRpcStructMember dataMember in dataStruct.Members) { var res = new CheckMovieHash2Result(); res.Name = dataMember.Name; @@ -2413,7 +2413,7 @@ namespace OpenSubtitlesHandler foreach (XmlRpcValueStruct movieStruct in dataArray.Values) { var d = new CheckMovieHash2Data(); - foreach (var movieMember in movieStruct.Members) + foreach (XmlRpcStructMember movieMember in movieStruct.Members) { switch (movieMember.Name) { @@ -2480,7 +2480,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseCheckSubHash(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2489,7 +2489,7 @@ namespace OpenSubtitlesHandler case "data": OSHConsole.WriteLine(">Data:"); var dataStruct = (XmlRpcValueStruct)MEMBER.Data; - foreach (var dataMember in dataStruct.Members) + foreach (XmlRpcStructMember dataMember in dataStruct.Members) { OSHConsole.WriteLine(" >" + dataMember.Name + "= " + dataMember.Data.Data.ToString()); var r = new CheckSubHashResult(); @@ -2565,7 +2565,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseTryUploadSubtitles(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { @@ -2578,13 +2578,13 @@ namespace OpenSubtitlesHandler OSHConsole.WriteLine("Results: "); var rarray = (XmlRpcValueArray)MEMBER.Data; - foreach (var subStruct in rarray.Values) + foreach (IXmlRpcValue subStruct in rarray.Values) { if (subStruct == null) continue; if (!(subStruct is XmlRpcValueStruct)) continue; var result = new SubtitleSearchResult(); - foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) + foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members) { // To avoid errors of arranged info or missing ones, let's do it with switch.. switch (submember.Name) @@ -2679,7 +2679,7 @@ namespace OpenSubtitlesHandler // CDS members int i = 1; - foreach (var cd in info.CDS) + foreach (UploadSubtitleParameters cd in info.CDS) { var member2 = new XmlRpcStructMember("cd" + i, null); var memberStruct2 = new XmlRpcValueStruct(new List()); @@ -2718,7 +2718,7 @@ namespace OpenSubtitlesHandler var R = new MethodResponseUploadSubtitles(); // To make sure response is not currepted by server, do it in loop - foreach (var MEMBER in mainStruct.Members) + foreach (XmlRpcStructMember MEMBER in mainStruct.Members) { switch (MEMBER.Name) { diff --git a/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs b/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs index b1351f9e3..a79a278fa 100644 --- a/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs +++ b/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs @@ -60,7 +60,7 @@ namespace XmlRpcHandler using (var XMLwrt = XmlWriter.Create(ms, sett)) { // Let's write the methods - foreach (var method in methods) + foreach (XmlRpcMethodCall method in methods) { XMLwrt.WriteStartElement("methodCall");//methodCall XMLwrt.WriteStartElement("methodName");//methodName @@ -68,7 +68,7 @@ namespace XmlRpcHandler XMLwrt.WriteEndElement();//methodName XMLwrt.WriteStartElement("params");//params // Write values - foreach (var p in method.Parameters) + foreach (IXmlRpcValue p in method.Parameters) { XMLwrt.WriteStartElement("param");//param if (p is XmlRpcValueBasic) @@ -124,7 +124,7 @@ namespace XmlRpcHandler { if (XMLread.Name == "param" && XMLread.IsStartElement()) { - var val = ReadValue(XMLread); + IXmlRpcValue val = ReadValue(XMLread); if (val != null) call.Parameters.Add(val); } @@ -190,7 +190,7 @@ namespace XmlRpcHandler { XMLwrt.WriteStartElement("value");//value XMLwrt.WriteStartElement("struct");//struct - foreach (var member in val.Members) + foreach (XmlRpcStructMember member in val.Members) { XMLwrt.WriteStartElement("member");//member @@ -221,7 +221,7 @@ namespace XmlRpcHandler XMLwrt.WriteStartElement("value");//value XMLwrt.WriteStartElement("array");//array XMLwrt.WriteStartElement("data");//data - foreach (var o in val.Values) + foreach (IXmlRpcValue o in val.Values) { if (o is XmlRpcValueBasic) { @@ -303,7 +303,7 @@ namespace XmlRpcHandler xmlReader.Read();// read name member.Name = ReadString(xmlReader); - var val = ReadValue(xmlReader, true); + IXmlRpcValue val = ReadValue(xmlReader, true); if (val != null) { member.Data = val; @@ -329,7 +329,7 @@ namespace XmlRpcHandler } else { - var val = ReadValue(xmlReader); + IXmlRpcValue val = ReadValue(xmlReader); if (val != null) array.Values.Add(val); } diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index b9894ca8f..b051b6718 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -161,7 +161,7 @@ namespace SocketHttpListener internal static bool Contains(this IEnumerable source, Func condition) { - foreach (var elm in source) + foreach (T elm in source) if (condition(elm)) return true; diff --git a/SocketHttpListener/Net/ChunkedInputStream.cs b/SocketHttpListener/Net/ChunkedInputStream.cs index 8d59a7907..06dcb3a17 100644 --- a/SocketHttpListener/Net/ChunkedInputStream.cs +++ b/SocketHttpListener/Net/ChunkedInputStream.cs @@ -73,7 +73,7 @@ namespace SocketHttpListener.Net protected override int ReadCore(byte[] buffer, int offset, int count) { - var ares = BeginReadCore(buffer, offset, count, null, null); + IAsyncResult ares = BeginReadCore(buffer, offset, count, null, null); return EndRead(ares); } @@ -115,7 +115,7 @@ namespace SocketHttpListener.Net private void OnRead(IAsyncResult base_ares) { - var rb = (ReadBufferState)base_ares.AsyncState; + ReadBufferState rb = (ReadBufferState)base_ares.AsyncState; var ares = rb.Ares; try { diff --git a/SocketHttpListener/Net/HttpConnection.cs b/SocketHttpListener/Net/HttpConnection.cs index e87503118..af1c081d9 100644 --- a/SocketHttpListener/Net/HttpConnection.cs +++ b/SocketHttpListener/Net/HttpConnection.cs @@ -269,7 +269,7 @@ namespace SocketHttpListener.Net Close(true); return; } - var listener = _epl.Listener; + HttpListener listener = _epl.Listener; if (_lastListener != listener) { RemoveConnection(); @@ -417,7 +417,7 @@ namespace SocketHttpListener.Net { try { - var response = _context.Response; + HttpListenerResponse response = _context.Response; response.StatusCode = status; response.ContentType = "text/html"; string description = HttpStatusDescription.Get(status); @@ -509,7 +509,7 @@ namespace SocketHttpListener.Net return; } - var s = _socket; + Socket s = _socket; _socket = null; try { diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs index c78d186c5..ea7d8fd2d 100644 --- a/SocketHttpListener/Net/HttpEndPointListener.cs +++ b/SocketHttpListener/Net/HttpEndPointListener.cs @@ -277,7 +277,7 @@ namespace SocketHttpListener.Net public bool BindContext(HttpListenerContext context) { var req = context.Request; - var listener = SearchListener(req.Url, out var prefix); + HttpListener listener = SearchListener(req.Url, out var prefix); if (listener == null) return false; @@ -309,7 +309,7 @@ namespace SocketHttpListener.Net if (host != null && host != "") { - var localPrefixes = _prefixes; + Dictionary localPrefixes = _prefixes; foreach (var p in localPrefixes.Keys) { string ppath = p.Path; @@ -330,7 +330,7 @@ namespace SocketHttpListener.Net return bestMatch; } - var list = _unhandledPrefixes; + List list = _unhandledPrefixes; bestMatch = MatchFromList(host, path, list, out prefix); if (path != pathSlash && bestMatch == null) @@ -360,7 +360,7 @@ namespace SocketHttpListener.Net HttpListener bestMatch = null; int bestLength = -1; - foreach (var p in list) + foreach (ListenerPrefix p in list) { string ppath = p.Path; if (ppath.Length < bestLength) @@ -382,7 +382,7 @@ namespace SocketHttpListener.Net if (list == null) return; - foreach (var p in list) + foreach (ListenerPrefix p in list) { if (p.Path == prefix.Path) throw new Exception("net_listener_already"); @@ -398,7 +398,7 @@ namespace SocketHttpListener.Net int c = list.Count; for (int i = 0; i < c; i++) { - var p = list[i]; + ListenerPrefix p = list[i]; if (p.Path == prefix.Path) { list.RemoveAt(i); @@ -413,7 +413,7 @@ namespace SocketHttpListener.Net if (_prefixes.Count > 0) return; - var list = _unhandledPrefixes; + List list = _unhandledPrefixes; if (list != null && list.Count > 0) return; @@ -433,7 +433,7 @@ namespace SocketHttpListener.Net // Clone the list because RemoveConnection can be called from Close var connections = new List(_unregisteredConnections.Keys); - foreach (var c in connections) + foreach (HttpConnection c in connections) c.Close(true); _unregisteredConnections.Clear(); } diff --git a/SocketHttpListener/Net/HttpEndPointManager.cs b/SocketHttpListener/Net/HttpEndPointManager.cs index 07b6331f2..a75af5f5d 100644 --- a/SocketHttpListener/Net/HttpEndPointManager.cs +++ b/SocketHttpListener/Net/HttpEndPointManager.cs @@ -74,7 +74,7 @@ namespace SocketHttpListener.Net throw new HttpListenerException((int)HttpStatusCode.BadRequest, "net_invalid_path"); // listens on all the interfaces if host name cannot be parsed by IPAddress. - var epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); + HttpEndPointListener epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); epl.AddPrefix(lp, listener); } @@ -185,7 +185,7 @@ namespace SocketHttpListener.Net if (lp.Path.IndexOf("//", StringComparison.Ordinal) != -1) return; - var epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); + HttpEndPointListener epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); epl.RemovePrefix(lp, listener); } } diff --git a/SocketHttpListener/Net/HttpListenerContext.Managed.cs b/SocketHttpListener/Net/HttpListenerContext.Managed.cs index 4cdb6882e..a6622c479 100644 --- a/SocketHttpListener/Net/HttpListenerContext.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerContext.Managed.cs @@ -44,7 +44,7 @@ namespace SocketHttpListener.Net } internal IPrincipal ParseBasicAuthentication(string authData) => - TryParseBasicAuth(authData, out var errorCode, out string username, out string password) ? + TryParseBasicAuth(authData, out HttpStatusCode errorCode, out string username, out string password) ? new GenericPrincipal(new HttpListenerBasicIdentity(username, password), Array.Empty()) : null; diff --git a/SocketHttpListener/Net/HttpListenerRequest.Managed.cs b/SocketHttpListener/Net/HttpListenerRequest.Managed.cs index 41d075045..3f9e32f08 100644 --- a/SocketHttpListener/Net/HttpListenerRequest.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerRequest.Managed.cs @@ -180,7 +180,7 @@ namespace SocketHttpListener.Net if (string.Compare(Headers[HttpKnownHeaderNames.Expect], "100-continue", StringComparison.OrdinalIgnoreCase) == 0) { - var output = _context.Connection.GetResponseStream(); + HttpResponseStream output = _context.Connection.GetResponseStream(); output.InternalWrite(s_100continue, 0, s_100continue.Length); } } @@ -256,7 +256,7 @@ namespace SocketHttpListener.Net { try { - var ares = InputStream.BeginRead(bytes, 0, length, null, null); + IAsyncResult ares = InputStream.BeginRead(bytes, 0, length, null, null); if (!ares.IsCompleted && !ares.AsyncWaitHandle.WaitOne(1000)) return false; if (InputStream.EndRead(ares) <= 0) diff --git a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs index 52e70b68b..7b4b619e6 100644 --- a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs +++ b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs @@ -94,10 +94,10 @@ namespace SocketHttpListener.Net // Try to check the raw path using first the primary encoding (according to http.sys settings); // if it fails try the secondary encoding. - var result = BuildRequestUriUsingRawPath(GetEncoding(EncodingType.Primary)); + ParsingResult result = BuildRequestUriUsingRawPath(GetEncoding(EncodingType.Primary)); if (result == ParsingResult.EncodingError) { - var secondaryEncoding = GetEncoding(EncodingType.Secondary); + Encoding secondaryEncoding = GetEncoding(EncodingType.Secondary); result = BuildRequestUriUsingRawPath(secondaryEncoding); } isValid = (result == ParsingResult.Success) ? true : false; @@ -136,7 +136,7 @@ namespace SocketHttpListener.Net _requestUriString.Append(Uri.SchemeDelimiter); _requestUriString.Append(_cookedUriHost); - var result = ParseRawPath(encoding); + ParsingResult result = ParseRawPath(encoding); if (result == ParsingResult.Success) { _requestUriString.Append(_cookedUriQuery); @@ -263,7 +263,7 @@ namespace SocketHttpListener.Net private bool AddPercentEncodedOctetToRawOctetsList(Encoding encoding, string escapedCharacter) { - if (!byte.TryParse(escapedCharacter, NumberStyles.HexNumber, null, out var encodedValue)) + if (!byte.TryParse(escapedCharacter, NumberStyles.HexNumber, null, out byte encodedValue)) { //if (NetEventSource.IsEnabled) NetEventSource.Error(this, SR.Format(SR.net_log_listener_cant_convert_percent_value, escapedCharacter)); return false; diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs index cda4fe8bc..5d02a9c95 100644 --- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs +++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs @@ -70,7 +70,7 @@ namespace SocketHttpListener.Net private void DisposeCore() { byte[] bytes = null; - var ms = GetHeaders(true); + MemoryStream ms = GetHeaders(true); bool chunked = _response.SendChunked; if (_stream.CanWrite) { @@ -110,7 +110,7 @@ namespace SocketHttpListener.Net if (_stream.CanWrite) { - var ms = GetHeaders(closing: false, isWebSocketHandshake: true); + MemoryStream ms = GetHeaders(closing: false, isWebSocketHandshake: true); bool chunked = _response.SendChunked; long start = ms.Position; @@ -146,7 +146,7 @@ namespace SocketHttpListener.Net return null; } - var ms = new MemoryStream(); + MemoryStream ms = new MemoryStream(); _response.SendHeaders(closing, ms, isWebSocketHandshake); return ms; } @@ -190,7 +190,7 @@ namespace SocketHttpListener.Net return; byte[] bytes = null; - var ms = GetHeaders(false); + MemoryStream ms = GetHeaders(false); bool chunked = _response.SendChunked; if (ms != null) { @@ -234,7 +234,7 @@ namespace SocketHttpListener.Net } byte[] bytes = null; - var ms = GetHeaders(false); + MemoryStream ms = GetHeaders(false); bool chunked = _response.SendChunked; if (ms != null) { diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs index c56d2ef38..34fca808b 100644 --- a/SocketHttpListener/Net/WebHeaderCollection.cs +++ b/SocketHttpListener/Net/WebHeaderCollection.cs @@ -208,7 +208,7 @@ namespace SocketHttpListener.Net if (!IsHeaderName(headerName)) throw new ArgumentException("Invalid character in header"); - if (!headers.TryGetValue(headerName, out var info)) + if (!headers.TryGetValue(headerName, out HeaderInfo info)) return false; var flag = response ? HeaderInfo.Response : HeaderInfo.Request; @@ -312,7 +312,7 @@ namespace SocketHttpListener.Net if (headerName == null) return false; - return headers.TryGetValue(headerName, out var info) && (info & HeaderInfo.MultiValue) != 0; + return headers.TryGetValue(headerName, out HeaderInfo info) && (info & HeaderInfo.MultiValue) != 0; } internal static bool IsHeaderValue(string value) diff --git a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs index 5f77ff565..1cfd2dc90 100644 --- a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs +++ b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs @@ -16,8 +16,8 @@ namespace SocketHttpListener.Net.WebSockets ValidateOptions(subProtocol, receiveBufferSize, MinSendBufferSize, keepAliveInterval); // get property will create a new response if one doesn't exist. - var response = context.Response; - var request = context.Request; + HttpListenerResponse response = context.Response; + HttpListenerRequest request = context.Request; ValidateWebSocketHeaders(context); string secWebSocketVersion = request.Headers[HttpKnownHeaderNames.SecWebSocketVersion]; diff --git a/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs b/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs index 3f61e55fc..0469e3b6c 100644 --- a/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs +++ b/SocketHttpListener/Net/WebSockets/WebSocketValidate.cs @@ -20,7 +20,7 @@ namespace SocketHttpListener.Net.WebSockets if (validStates != null && validStates.Length > 0) { - foreach (var validState in validStates) + foreach (WebSocketState validState in validStates) { if (currentState == validState) { diff --git a/SocketHttpListener/WebSocket.cs b/SocketHttpListener/WebSocket.cs index e5b3f89bc..bf400599d 100644 --- a/SocketHttpListener/WebSocket.cs +++ b/SocketHttpListener/WebSocket.cs @@ -78,6 +78,7 @@ namespace SocketHttpListener init(); } + // In the .NET Framework, this pulls the value from a P/Invoke. Here we just hardcode it to a reasonable default. public static TimeSpan DefaultKeepAliveInterval => TimeSpan.FromSeconds(30); #endregion -- cgit v1.2.3