ReSharper format: conform inline 'out' parameters.

This commit is contained in:
Erwin de Haan 2019-01-13 21:46:33 +01:00
parent 65bd052f3e
commit e867446437
124 changed files with 354 additions and 820 deletions

View File

@ -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<ushort>();
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);

View File

@ -192,9 +192,7 @@ namespace Emby.Dlna.ContentDirectory
public string GetValueOrDefault(IDictionary<string, string> 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);

View File

@ -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<InternalProfileInfo, DeviceProfile> profileTuple;
if (_profiles.TryGetValue(path, out profileTuple))
if (_profiles.TryGetValue(path, out var profileTuple))
{
return profileTuple.Item2;
}

View File

@ -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.");
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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++;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<int?, bool>(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<int?, bool>(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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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");

View File

@ -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;

View File

@ -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)
{

View File

@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -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))
{

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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>

View File

@ -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;
}

View File

@ -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--;

View File

@ -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
{

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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))
{

View File

@ -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;
}

View File

@ -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");
}

View File

@ -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;

View File

@ -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))
{

View File

@ -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
{

View File

@ -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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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;
}
}

View File

@ -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))
{

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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>

View File

@ -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();
}

View File

@ -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)

View File

@ -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;

View File

@ -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;
}

View File

@ -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 };
}

View File

@ -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;
}

View File

@ -413,10 +413,9 @@ namespace MediaBrowser.Api.Session
/// <param name="request">The request.</param>
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();
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -50,11 +50,9 @@ namespace MediaBrowser.Controller.Entities
public IList<BaseItem> 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<BaseItem>();
}
@ -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;
}

View File

@ -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[]
{

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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<string> GetFilePaths(string path, bool clearCache)
{
List<string> result;
if (clearCache || !_filePathCache.TryGetValue(path, out result))
if (clearCache || !_filePathCache.TryGetValue(path, out var result))
{
result = _fileSystem.GetFilePaths(path).ToList();

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<Guid, MetadataRefreshOptions> 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)
{

View File

@ -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;

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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))
{

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<string, string> 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;
}

View File

@ -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();
}

Some files were not shown because too many files have changed in this diff Show More