aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorErwin de Haan <EraYaN@users.noreply.github.com>2019-01-13 21:46:33 +0100
committerErwin de Haan <EraYaN@users.noreply.github.com>2019-01-13 21:46:33 +0100
commite8674464373c3635243953cded42fcd2aa87d196 (patch)
tree8087e1c5d47a525b04f3ae7e99183f68391bb410 /Emby.Server.Implementations
parent65bd052f3e8682d177520af57db1c8ef5cb33262 (diff)
ReSharper format: conform inline 'out' parameters.
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Channels/ChannelManager.cs4
-rw-r--r--Emby.Server.Implementations/Data/SqliteExtensions.cs34
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs29
-rw-r--r--Emby.Server.Implementations/Devices/DeviceId.cs3
-rw-r--r--Emby.Server.Implementations/Devices/DeviceManager.cs3
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs4
-rw-r--r--Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs12
-rw-r--r--Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs3
-rw-r--r--Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs4
-rw-r--r--Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs4
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpListenerHost.cs12
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpResultFactory.cs17
-rw-r--r--Emby.Server.Implementations/HttpServer/ResponseFilter.cs3
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/AuthService.cs3
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs3
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/SessionContext.cs3
-rw-r--r--Emby.Server.Implementations/IO/LibraryMonitor.cs11
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs7
-rw-r--r--Emby.Server.Implementations/Library/MediaSourceManager.cs7
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs30
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs3
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs6
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs3
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs9
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs3
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs33
-rw-r--r--Emby.Server.Implementations/Localization/LocalizationManager.cs16
-rw-r--r--Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs39
-rw-r--r--Emby.Server.Implementations/Networking/NetworkManager.cs20
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/TaskManager.cs3
-rw-r--r--Emby.Server.Implementations/Security/MBLicenseFile.cs9
-rw-r--r--Emby.Server.Implementations/Serialization/XmlSerializer.cs3
-rw-r--r--Emby.Server.Implementations/Services/ServiceController.cs3
-rw-r--r--Emby.Server.Implementations/Services/ServiceExec.cs3
-rw-r--r--Emby.Server.Implementations/Services/ServiceHandler.cs9
-rw-r--r--Emby.Server.Implementations/Services/ServicePath.cs6
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs6
-rw-r--r--Emby.Server.Implementations/TextEncoding/NLangDetect/ProbVector.cs4
-rw-r--r--Emby.Server.Implementations/TextEncoding/NLangDetect/Utils/Messages.cs4
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs4
40 files changed, 119 insertions, 263 deletions
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<IEnumerable<MediaSourceInfo>> GetChannelItemMediaSourcesInternal(IRequiresMediaInfoCallback channel, string id, CancellationToken cancellationToken)
{
- Tuple<DateTime, List<MediaSourceInfo>> 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<string> 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<BaseItem> keys;
-
- if (!_changedItems.TryGetValue(e.UserId, out keys))
+ if (!_changedItems.TryGetValue(e.UserId, out var keys))
{
keys = new List<BaseItem>();
_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, string>();
}
- 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, string>();
}
- 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, string>();
}
- 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
/// <param name="path">The path.</param>
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
/// <param name="watcher">The watcher.</param>
private void RemoveWatcherFromList(FileSystemWatcher watcher)
{
- FileSystemWatcher removed;
-
- _fileSystemWatchers.TryRemove(watcher.Path, out removed);
+ _fileSystemWatchers.TryRemove(watcher.Path, out var removed);
}
/// <summary>
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<EpgChannelData> 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<string>(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
/// <param name="countryCode">The country code.</param>
private Dictionary<string, ParentalRating> GetRatings(string countryCode)
{
- Dictionary<string, ParentalRating> 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
/// <returns></returns>
public static BigInteger ToBigInteger(IPAddress ipaddress)
{
- BigInteger? uintIpAddress = null;
- IPNetwork.InternalToBigInteger(false, ipaddress, out uintIpAddress);
+ IPNetwork.InternalToBigInteger(false, ipaddress, out var uintIpAddress);
return (BigInteger)uintIpAddress;
}
@@ -630,8 +628,7 @@ namespace System.Net
/// <returns></returns>
public static bool TryToBigInteger(IPAddress ipaddress, out BigInteger? uintIpAddress)
{
- BigInteger? uintIpAddress2 = null;
- IPNetwork.InternalToBigInteger(true, ipaddress, out uintIpAddress2);
+ IPNetwork.InternalToBigInteger(true, ipaddress, out var uintIpAddress2);
bool parsed = (uintIpAddress2 != null);
uintIpAddress = uintIpAddress2;
return parsed;
@@ -681,9 +678,7 @@ namespace System.Net
/// <returns></returns>
public static BigInteger ToUint(byte cidr, AddressFamily family)
{
-
- BigInteger? uintNetmask = null;
- IPNetwork.InternalToBigInteger(false, cidr, family, out uintNetmask);
+ IPNetwork.InternalToBigInteger(false, cidr, family, out var uintNetmask);
return (BigInteger)uintNetmask;
}
@@ -695,9 +690,7 @@ namespace System.Net
/// <returns></returns>
public static bool TryToUint(byte cidr, AddressFamily family, out BigInteger? uintNetmask)
{
-
- BigInteger? uintNetmask2 = null;
- IPNetwork.InternalToBigInteger(true, cidr, family, out uintNetmask2);
+ IPNetwork.InternalToBigInteger(true, cidr, family, out var uintNetmask2);
bool parsed = (uintNetmask2 != null);
uintNetmask = uintNetmask2;
return parsed;
@@ -812,8 +805,7 @@ namespace System.Net
/// <returns></returns>
public static byte ToCidr(IPAddress netmask)
{
- byte? cidr = null;
- IPNetwork.InternalToCidr(false, netmask, out cidr);
+ IPNetwork.InternalToCidr(false, netmask, out var cidr);
return (byte)cidr;
}
@@ -827,8 +819,7 @@ namespace System.Net
/// <returns></returns>
public static bool TryToCidr(IPAddress netmask, out byte? cidr)
{
- byte? cidr2 = null;
- IPNetwork.InternalToCidr(true, netmask, out cidr2);
+ IPNetwork.InternalToCidr(true, netmask, out var cidr2);
bool parsed = (cidr2 != null);
cidr = cidr2;
return parsed;
@@ -846,8 +837,8 @@ namespace System.Net
cidr = null;
return;
}
- BigInteger? uintNetmask2 = null;
- bool parsed = IPNetwork.TryToBigInteger(netmask, out uintNetmask2);
+
+ bool parsed = IPNetwork.TryToBigInteger(netmask, out var uintNetmask2);
/// 20180217 lduchosal
/// impossible to reach code.
@@ -860,8 +851,7 @@ namespace System.Net
/// }
var uintNetmask = (BigInteger)uintNetmask2;
- byte? cidr2 = null;
- IPNetwork.InternalToCidr(tryParse, uintNetmask, netmask.AddressFamily, out cidr2);
+ IPNetwork.InternalToCidr(tryParse, uintNetmask, netmask.AddressFamily, out var cidr2);
cidr = cidr2;
return;
@@ -1491,8 +1481,7 @@ namespace System.Net
/// <returns></returns>
public static IPNetwork[] Supernet(IPNetwork[] ipnetworks)
{
- IPNetwork[] supernet;
- InternalSupernet(false, ipnetworks, out supernet);
+ InternalSupernet(false, ipnetworks, out var supernet);
return supernet;
}
@@ -1642,14 +1631,12 @@ namespace System.Net
throw new ArgumentNullException(nameof(end));
}
- IPAddress startIP;
- if (!IPAddress.TryParse(start, out startIP))
+ if (!IPAddress.TryParse(start, out var startIP))
{
throw new ArgumentException("start");
}
- IPAddress endIP;
- if (!IPAddress.TryParse(end, out endIP))
+ if (!IPAddress.TryParse(end, out var endIP))
{
throw new ArgumentException("end");
}
diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs
index 70d8376a9..b486c0ef7 100644
--- a/Emby.Server.Implementations/Networking/NetworkManager.cs
+++ b/Emby.Server.Implementations/Networking/NetworkManager.cs
@@ -203,11 +203,9 @@ namespace Emby.Server.Implementations.Networking
private Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
private List<string> GetSubnets(string endpointFirstPart)
{
- List<string> subnets;
-
lock (_subnetLookup)
{
- if (_subnetLookup.TryGetValue(endpointFirstPart, out subnets))
+ if (_subnetLookup.TryGetValue(endpointFirstPart, out var subnets))
{
return subnets;
}
@@ -298,8 +296,7 @@ namespace Emby.Server.Implementations.Networking
throw new ArgumentNullException(nameof(endpoint));
}
- IPAddress address;
- if (IPAddress.TryParse(endpoint, out address))
+ if (IPAddress.TryParse(endpoint, out var address))
{
var addressString = address.ToString();
@@ -348,8 +345,7 @@ namespace Emby.Server.Implementations.Networking
}
else if (resolveHost)
{
- Uri uri;
- if (Uri.TryCreate(endpoint, UriKind.RelativeOrAbsolute, out uri))
+ if (Uri.TryCreate(endpoint, UriKind.RelativeOrAbsolute, out var uri))
{
try
{
@@ -588,9 +584,7 @@ namespace Emby.Server.Implementations.Networking
/// <exception cref="FormatException"></exception>
private static int GetPort(string p)
{
- int port;
-
- if (!int.TryParse(p, out port)
+ if (!int.TryParse(p, out var port)
|| port < IPEndPoint.MinPort
|| port > IPEndPoint.MaxPort)
{
@@ -618,8 +612,7 @@ namespace Emby.Server.Implementations.Networking
public IpAddressInfo ParseIpAddress(string ipAddress)
{
- IpAddressInfo info;
- if (TryParseIpAddress(ipAddress, out info))
+ if (TryParseIpAddress(ipAddress, out var info))
{
return info;
}
@@ -629,8 +622,7 @@ namespace Emby.Server.Implementations.Networking
public bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo)
{
- IPAddress address;
- if (IPAddress.TryParse(ipAddress, out address))
+ if (IPAddress.TryParse(ipAddress, out var address))
{
ipAddressInfo = ToIpAddressInfo(address);
return true;
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<Type, TaskOptions>>();
- Tuple<Type, TaskOptions> 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<RestPath> pathsAtFirstMatch;
- if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out pathsAtFirstMatch))
+ if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out var pathsAtFirstMatch))
{
pathsAtFirstMatch = new List<RestPath>();
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<string, string> 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;
}
/// <summary>