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

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