mirror of https://github.com/Radarr/Radarr
Inline 'out' variable declarations
(cherry picked from commit 281add47de1d3940990156c841362125dea9cc7d)
This commit is contained in:
parent
ed68a944ea
commit
8762588ef0
|
@ -47,8 +47,7 @@ namespace NzbDrone.Common.Cache
|
|||
|
||||
public T Find(string key)
|
||||
{
|
||||
CacheItem cacheItem;
|
||||
if (!_store.TryGetValue(key, out cacheItem))
|
||||
if (!_store.TryGetValue(key, out var cacheItem))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
@ -76,8 +75,7 @@ namespace NzbDrone.Common.Cache
|
|||
|
||||
public void Remove(string key)
|
||||
{
|
||||
CacheItem value;
|
||||
_store.TryRemove(key, out value);
|
||||
_store.TryRemove(key, out _);
|
||||
}
|
||||
|
||||
public int Count => _store.Count;
|
||||
|
@ -88,9 +86,7 @@ namespace NzbDrone.Common.Cache
|
|||
|
||||
lifeTime = lifeTime ?? _defaultLifeTime;
|
||||
|
||||
CacheItem cacheItem;
|
||||
|
||||
if (_store.TryGetValue(key, out cacheItem) && !cacheItem.IsExpired())
|
||||
if (_store.TryGetValue(key, out var cacheItem) && !cacheItem.IsExpired())
|
||||
{
|
||||
if (_rollingExpiry && lifeTime.HasValue)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -86,9 +86,7 @@ namespace NzbDrone.Common.Cache
|
|||
{
|
||||
RefreshIfExpired();
|
||||
|
||||
TValue result;
|
||||
|
||||
if (!_items.TryGetValue(key, out result))
|
||||
if (!_items.TryGetValue(key, out var result))
|
||||
{
|
||||
throw new KeyNotFoundException(string.Format("Item {0} not found in cache.", key));
|
||||
}
|
||||
|
@ -100,9 +98,7 @@ namespace NzbDrone.Common.Cache
|
|||
{
|
||||
RefreshIfExpired();
|
||||
|
||||
TValue result;
|
||||
|
||||
_items.TryGetValue(key, out result);
|
||||
_items.TryGetValue(key, out var result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -128,8 +124,7 @@ namespace NzbDrone.Common.Cache
|
|||
|
||||
public void Remove(string key)
|
||||
{
|
||||
TValue item;
|
||||
_items.TryRemove(key, out item);
|
||||
_items.TryRemove(key, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,7 @@ namespace NzbDrone.Common.Extensions
|
|||
{
|
||||
public static int? ParseInt32(this string source)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (int.TryParse(source, out result))
|
||||
if (int.TryParse(source, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -18,9 +16,7 @@ namespace NzbDrone.Common.Extensions
|
|||
|
||||
public static long? ParseInt64(this string source)
|
||||
{
|
||||
long result;
|
||||
|
||||
if (long.TryParse(source, out result))
|
||||
if (long.TryParse(source, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -30,9 +26,7 @@ namespace NzbDrone.Common.Extensions
|
|||
|
||||
public static double? ParseDouble(this string source)
|
||||
{
|
||||
double result;
|
||||
|
||||
if (double.TryParse(source.Replace(',', '.'), NumberStyles.Number, CultureInfo.InvariantCulture, out result))
|
||||
if (double.TryParse(source.Replace(',', '.'), NumberStyles.Number, CultureInfo.InvariantCulture, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -12,14 +12,12 @@ namespace NzbDrone.Common.Http
|
|||
if (response.Headers.ContainsKey("Retry-After"))
|
||||
{
|
||||
var retryAfter = response.Headers["Retry-After"].ToString();
|
||||
int seconds;
|
||||
DateTime date;
|
||||
|
||||
if (int.TryParse(retryAfter, out seconds))
|
||||
if (int.TryParse(retryAfter, out var seconds))
|
||||
{
|
||||
RetryAfter = TimeSpan.FromSeconds(seconds);
|
||||
}
|
||||
else if (DateTime.TryParse(retryAfter, out date))
|
||||
else if (DateTime.TryParse(retryAfter, out var date))
|
||||
{
|
||||
RetryAfter = date.ToUniversalTime() - DateTime.UtcNow;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
@ -60,14 +60,11 @@ namespace NzbDrone.Core.Test.Framework
|
|||
{
|
||||
var columnName = dataRow.Table.Columns[i].ColumnName;
|
||||
|
||||
object value;
|
||||
if (dataRow.ItemArray[i] == DBNull.Value)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = dataRow.ItemArray[i];
|
||||
}
|
||||
|
||||
item[columnName] = dataRow.ItemArray[i];
|
||||
|
|
|
@ -119,8 +119,7 @@ namespace NzbDrone.Core.Configuration
|
|||
continue;
|
||||
}
|
||||
|
||||
object currentValue;
|
||||
allWithDefaults.TryGetValue(configValue.Key, out currentValue);
|
||||
allWithDefaults.TryGetValue(configValue.Key, out var currentValue);
|
||||
if (currentValue == null)
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -57,8 +57,7 @@ namespace NzbDrone.Core.Configuration
|
|||
|
||||
foreach (var configValue in configValues)
|
||||
{
|
||||
object currentValue;
|
||||
allWithDefaults.TryGetValue(configValue.Key, out currentValue);
|
||||
allWithDefaults.TryGetValue(configValue.Key, out var currentValue);
|
||||
if (currentValue == null || configValue.Value == null)
|
||||
{
|
||||
continue;
|
||||
|
@ -457,9 +456,7 @@ namespace NzbDrone.Core.Configuration
|
|||
|
||||
EnsureCache();
|
||||
|
||||
string dbValue;
|
||||
|
||||
if (_cache.TryGetValue(key, out dbValue) && dbValue != null && !string.IsNullOrEmpty(dbValue))
|
||||
if (_cache.TryGetValue(key, out var dbValue) && dbValue != null && !string.IsNullOrEmpty(dbValue))
|
||||
{
|
||||
return dbValue;
|
||||
}
|
||||
|
|
|
@ -259,9 +259,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
|||
protected long GetRemainingSize(DownloadStationTask torrent)
|
||||
{
|
||||
var downloadedString = torrent.Additional.Transfer["size_downloaded"];
|
||||
long downloadedSize;
|
||||
|
||||
if (downloadedString.IsNullOrWhiteSpace() || !long.TryParse(downloadedString, out downloadedSize))
|
||||
if (downloadedString.IsNullOrWhiteSpace() || !long.TryParse(downloadedString, out var downloadedSize))
|
||||
{
|
||||
_logger.Debug("Torrent {0} has invalid size_downloaded: {1}", torrent.Title, downloadedString);
|
||||
downloadedSize = 0;
|
||||
|
@ -273,9 +272,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
|||
protected TimeSpan? GetRemainingTime(DownloadStationTask torrent)
|
||||
{
|
||||
var speedString = torrent.Additional.Transfer["speed_download"];
|
||||
long downloadSpeed;
|
||||
|
||||
if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out downloadSpeed))
|
||||
if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out var downloadSpeed))
|
||||
{
|
||||
_logger.Debug("Torrent {0} has invalid speed_download: {1}", torrent.Title, speedString);
|
||||
downloadSpeed = 0;
|
||||
|
|
|
@ -355,9 +355,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
|||
protected long GetRemainingSize(DownloadStationTask task)
|
||||
{
|
||||
var downloadedString = task.Additional.Transfer["size_downloaded"];
|
||||
long downloadedSize;
|
||||
|
||||
if (downloadedString.IsNullOrWhiteSpace() || !long.TryParse(downloadedString, out downloadedSize))
|
||||
if (downloadedString.IsNullOrWhiteSpace() || !long.TryParse(downloadedString, out var downloadedSize))
|
||||
{
|
||||
_logger.Debug("Task {0} has invalid size_downloaded: {1}", task.Title, downloadedString);
|
||||
downloadedSize = 0;
|
||||
|
@ -369,9 +368,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
|||
protected long GetDownloadSpeed(DownloadStationTask task)
|
||||
{
|
||||
var speedString = task.Additional.Transfer["speed_download"];
|
||||
long downloadSpeed;
|
||||
|
||||
if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out downloadSpeed))
|
||||
if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out var downloadSpeed))
|
||||
{
|
||||
_logger.Debug("Task {0} has invalid speed_download: {1}", task.Title, speedString);
|
||||
downloadSpeed = 0;
|
||||
|
|
|
@ -15,8 +15,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex.JsonConverters
|
|||
{
|
||||
var result = reader.Value.ToString().Replace("_", string.Empty);
|
||||
|
||||
NzbVortexLoginResultType output;
|
||||
Enum.TryParse(result, true, out output);
|
||||
Enum.TryParse(result, true, out NzbVortexLoginResultType output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex.JsonConverters
|
|||
{
|
||||
var result = reader.Value.ToString().Replace("_", string.Empty);
|
||||
|
||||
NzbVortexResultType output;
|
||||
Enum.TryParse(result, true, out output);
|
||||
Enum.TryParse(result, true, out NzbVortexResultType output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -124,9 +124,8 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
|
|||
public override void RemoveItem(DownloadClientItem item, bool deleteData)
|
||||
{
|
||||
// Try to find the download by numerical ID, otherwise try by AddUUID
|
||||
int id;
|
||||
|
||||
if (int.TryParse(item.DownloadId, out id))
|
||||
if (int.TryParse(item.DownloadId, out var id))
|
||||
{
|
||||
_proxy.Remove(id, deleteData, Settings);
|
||||
}
|
||||
|
|
|
@ -313,8 +313,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
|||
var config = _proxy.GetConfig(Settings);
|
||||
|
||||
var keepHistory = config.GetValueOrDefault("KeepHistory", "7");
|
||||
int value;
|
||||
if (!int.TryParse(keepHistory, NumberStyles.None, CultureInfo.InvariantCulture, out value) || value == 0)
|
||||
if (!int.TryParse(keepHistory, NumberStyles.None, CultureInfo.InvariantCulture, out var value) || value == 0)
|
||||
{
|
||||
return new NzbDroneValidationFailure(string.Empty, "NzbGet setting KeepHistory should be greater than 0")
|
||||
{
|
||||
|
|
|
@ -164,11 +164,10 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
|||
var queue = GetQueue(settings);
|
||||
var history = GetHistory(settings);
|
||||
|
||||
int nzbId;
|
||||
NzbgetQueueItem queueItem;
|
||||
NzbgetHistoryItem historyItem;
|
||||
|
||||
if (id.Length < 10 && int.TryParse(id, out nzbId))
|
||||
if (id.Length < 10 && int.TryParse(id, out var nzbId))
|
||||
{
|
||||
// Download wasn't grabbed by Radarr, so the id is the NzbId reported by nzbget.
|
||||
queueItem = queue.SingleOrDefault(h => h.NzbId == nzbId);
|
||||
|
|
|
@ -15,8 +15,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
|
|||
{
|
||||
var queuePriority = reader.Value.ToString();
|
||||
|
||||
SabnzbdPriority output;
|
||||
Enum.TryParse(queuePriority, out output);
|
||||
Enum.TryParse(queuePriority, out SabnzbdPriority output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
|||
|
||||
request.AddFormUpload("name", filename, nzbData, "application/x-nzb");
|
||||
|
||||
SabnzbdAddResponse response;
|
||||
|
||||
if (!Json.TryDeserialize<SabnzbdAddResponse>(ProcessRequest(request, settings), out response))
|
||||
if (!Json.TryDeserialize<SabnzbdAddResponse>(ProcessRequest(request, settings), out var response))
|
||||
{
|
||||
response = new SabnzbdAddResponse();
|
||||
response.Status = true;
|
||||
|
@ -76,9 +74,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
|||
{
|
||||
var request = BuildRequest("version", settings);
|
||||
|
||||
SabnzbdVersionResponse response;
|
||||
|
||||
if (!Json.TryDeserialize<SabnzbdVersionResponse>(ProcessRequest(request, settings), out response))
|
||||
if (!Json.TryDeserialize<SabnzbdVersionResponse>(ProcessRequest(request, settings), out var response))
|
||||
{
|
||||
response = new SabnzbdVersionResponse();
|
||||
}
|
||||
|
@ -142,9 +138,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
|||
var request = BuildRequest("retry", settings);
|
||||
request.AddQueryParam("value", id);
|
||||
|
||||
SabnzbdRetryResponse response;
|
||||
|
||||
if (!Json.TryDeserialize<SabnzbdRetryResponse>(ProcessRequest(request, settings), out response))
|
||||
if (!Json.TryDeserialize<SabnzbdRetryResponse>(ProcessRequest(request, settings), out var response))
|
||||
{
|
||||
response = new SabnzbdRetryResponse();
|
||||
response.Status = true;
|
||||
|
@ -215,9 +209,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
|||
|
||||
private void CheckForError(HttpResponse response)
|
||||
{
|
||||
SabnzbdJsonError result;
|
||||
|
||||
if (!Json.TryDeserialize<SabnzbdJsonError>(response.Content, out result))
|
||||
if (!Json.TryDeserialize<SabnzbdJsonError>(response.Content, out var result))
|
||||
{
|
||||
// Handle plain text responses from SAB
|
||||
result = new SabnzbdJsonError();
|
||||
|
|
|
@ -56,8 +56,7 @@ namespace NzbDrone.Core.Download.Clients.Vuze
|
|||
|
||||
_logger.Debug("Vuze protocol version information: {0}", versionString);
|
||||
|
||||
int version;
|
||||
if (!int.TryParse(versionString, out version) || version < MINIMUM_SUPPORTED_PROTOCOL_VERSION)
|
||||
if (!int.TryParse(versionString, out var version) || version < MINIMUM_SUPPORTED_PROTOCOL_VERSION)
|
||||
{
|
||||
{
|
||||
return new ValidationFailure(string.Empty, "Protocol version not supported, use Vuze 5.0.0.0 or higher with Vuze Web Remote plugin.");
|
||||
|
|
|
@ -60,8 +60,7 @@ namespace NzbDrone.Core.Download
|
|||
|
||||
foreach (var client in clients)
|
||||
{
|
||||
DownloadClientStatus downloadClientStatus;
|
||||
if (blockedIndexers.TryGetValue(client.Definition.Id, out downloadClientStatus))
|
||||
if (blockedIndexers.TryGetValue(client.Definition.Id, out var downloadClientStatus))
|
||||
{
|
||||
_logger.Debug("Temporarily ignoring download client {0} till {1} due to recent failures.", client.Definition.Name, downloadClientStatus.DisabledTill.Value.ToLocalTime());
|
||||
continue;
|
||||
|
|
|
@ -160,8 +160,7 @@ namespace NzbDrone.Core.HealthCheck
|
|||
_isRunningHealthChecksAfterGracePeriod = false;
|
||||
}
|
||||
|
||||
IEventDrivenHealthCheck[] checks;
|
||||
if (!_eventDrivenHealthChecks.TryGetValue(message.GetType(), out checks))
|
||||
if (!_eventDrivenHealthChecks.TryGetValue(message.GetType(), out var checks))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -88,8 +88,7 @@ namespace NzbDrone.Core.Indexers
|
|||
|
||||
foreach (var indexer in indexers)
|
||||
{
|
||||
IndexerStatus blockedIndexerStatus;
|
||||
if (blockedIndexers.TryGetValue(indexer.Definition.Id, out blockedIndexerStatus))
|
||||
if (blockedIndexers.TryGetValue(indexer.Definition.Id, out var blockedIndexerStatus))
|
||||
{
|
||||
_logger.Debug("Temporarily ignoring indexer {0} till {1} due to recent failures.", indexer.Definition.Name, blockedIndexerStatus.DisabledTill.Value.ToLocalTime());
|
||||
continue;
|
||||
|
|
|
@ -131,10 +131,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
|
||||
protected override long GetSize(XElement item)
|
||||
{
|
||||
long size;
|
||||
|
||||
var sizeString = TryGetNewznabAttribute(item, "size");
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out size))
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out var size))
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
@ -170,9 +168,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
protected virtual int GetImdbId(XElement item)
|
||||
{
|
||||
var imdbIdString = TryGetNewznabAttribute(item, "imdb");
|
||||
int imdbId;
|
||||
|
||||
if (!imdbIdString.IsNullOrWhiteSpace() && int.TryParse(imdbIdString, out imdbId))
|
||||
if (!imdbIdString.IsNullOrWhiteSpace() && int.TryParse(imdbIdString, out var imdbId))
|
||||
{
|
||||
return imdbId;
|
||||
}
|
||||
|
@ -196,9 +193,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
protected virtual int GetImdbYear(XElement item)
|
||||
{
|
||||
var imdbYearString = TryGetNewznabAttribute(item, "imdbyear");
|
||||
int imdbYear;
|
||||
|
||||
if (!imdbYearString.IsNullOrWhiteSpace() && int.TryParse(imdbYearString, out imdbYear))
|
||||
if (!imdbYearString.IsNullOrWhiteSpace() && int.TryParse(imdbYearString, out var imdbYear))
|
||||
{
|
||||
return imdbYear;
|
||||
}
|
||||
|
|
|
@ -127,10 +127,8 @@ namespace NzbDrone.Core.Indexers.Torznab
|
|||
|
||||
protected override long GetSize(XElement item)
|
||||
{
|
||||
long size;
|
||||
|
||||
var sizeString = TryGetTorznabAttribute(item, "size");
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out size))
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out var size))
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
@ -247,9 +245,7 @@ namespace NzbDrone.Core.Indexers.Torznab
|
|||
{
|
||||
var attr = TryGetTorznabAttribute(item, key, defaultValue.ToString());
|
||||
|
||||
float result = 0;
|
||||
|
||||
if (float.TryParse(attr, out result))
|
||||
if (float.TryParse(attr, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
@ -37,8 +37,7 @@ namespace NzbDrone.Core.Indexers
|
|||
{
|
||||
try
|
||||
{
|
||||
DateTime result;
|
||||
if (!DateTime.TryParse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal, out result))
|
||||
if (!DateTime.TryParse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal, out var result))
|
||||
{
|
||||
dateString = RemoveTimeZoneRegex.Replace(dateString, "");
|
||||
result = DateTime.Parse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal);
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators
|
|||
public LocalMovie Aggregate(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
var languages = new List<Language> { localMovie.Movie?.MovieMetadata.Value.OriginalLanguage ?? Language.Unknown };
|
||||
var languagesConfidence = Confidence.Default;
|
||||
|
||||
foreach (var augmentLanguage in _augmentLanguages)
|
||||
{
|
||||
|
@ -38,7 +37,6 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators
|
|||
if (augmentedLanguage?.Languages != null && augmentedLanguage.Languages.Count > 0 && !(augmentedLanguage.Languages.Count == 1 && augmentedLanguage.Languages.Contains(Language.Unknown)))
|
||||
{
|
||||
languages = augmentedLanguage.Languages;
|
||||
languagesConfidence = augmentedLanguage.Confidence;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
private bool ChangeFileDate(string filePath, DateTime date)
|
||||
{
|
||||
DateTime oldDateTime;
|
||||
|
||||
if (DateTime.TryParse(_diskProvider.FileGetLastWrite(filePath).ToLongDateString(), out oldDateTime))
|
||||
if (DateTime.TryParse(_diskProvider.FileGetLastWrite(filePath).ToLongDateString(), out var oldDateTime))
|
||||
{
|
||||
if (!DateTime.Equals(date, oldDateTime))
|
||||
{
|
||||
|
|
|
@ -75,8 +75,7 @@ namespace NzbDrone.Core.Messaging.Events
|
|||
EventSubscribers<TEvent> subscribers;
|
||||
lock (_eventSubscribers)
|
||||
{
|
||||
object target;
|
||||
if (!_eventSubscribers.TryGetValue(eventName, out target))
|
||||
if (!_eventSubscribers.TryGetValue(eventName, out var target))
|
||||
{
|
||||
_eventSubscribers[eventName] = target = new EventSubscribers<TEvent>(_serviceFactory);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ namespace NzbDrone.Core.Movies.Collections
|
|||
var existingMetadata = GetByTmdbId(data.Select(x => x.TmdbId).ToList());
|
||||
var updateCollectionList = new List<MovieCollection>();
|
||||
var addCollectionList = new List<MovieCollection>();
|
||||
int upToDateMetadataCount = 0;
|
||||
|
||||
foreach (var collection in data)
|
||||
{
|
||||
|
@ -50,7 +49,6 @@ namespace NzbDrone.Core.Movies.Collections
|
|||
}
|
||||
else
|
||||
{
|
||||
upToDateMetadataCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -55,9 +55,7 @@ namespace NzbDrone.Core.Movies
|
|||
builder,
|
||||
(metadata, translation) =>
|
||||
{
|
||||
MovieMetadata movieEntry;
|
||||
|
||||
if (!movieDictionary.TryGetValue(metadata.Id, out movieEntry))
|
||||
if (!movieDictionary.TryGetValue(metadata.Id, out var movieEntry))
|
||||
{
|
||||
movieEntry = metadata;
|
||||
movieDictionary.Add(movieEntry.Id, movieEntry);
|
||||
|
|
|
@ -56,9 +56,7 @@ namespace NzbDrone.Core.Movies
|
|||
|
||||
private Movie Map(Dictionary<int, Movie> dict, Movie movie, Profile profile, MovieFile movieFile, AlternativeTitle altTitle = null, MovieTranslation translation = null)
|
||||
{
|
||||
Movie movieEntry;
|
||||
|
||||
if (!dict.TryGetValue(movie.Id, out movieEntry))
|
||||
if (!dict.TryGetValue(movie.Id, out var movieEntry))
|
||||
{
|
||||
movieEntry = movie;
|
||||
movieEntry.Profile = profile;
|
||||
|
|
|
@ -30,9 +30,7 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
|
|||
var request = BuildRequest(clientIdentifier);
|
||||
request.ResourceUrl = $"/api/v2/pins/{pinId}";
|
||||
|
||||
PlexTvPinResponse response;
|
||||
|
||||
if (!Json.TryDeserialize<PlexTvPinResponse>(ProcessRequest(request), out response))
|
||||
if (!Json.TryDeserialize<PlexTvPinResponse>(ProcessRequest(request), out var response))
|
||||
{
|
||||
response = new PlexTvPinResponse();
|
||||
}
|
||||
|
|
|
@ -152,14 +152,13 @@ namespace NzbDrone.Core.Notifications.PushBullet
|
|||
private HttpRequestBuilder BuildDeviceRequest(string deviceId)
|
||||
{
|
||||
var requestBuilder = new HttpRequestBuilder(PUSH_URL).Post();
|
||||
long integerId;
|
||||
|
||||
if (deviceId.IsNullOrWhiteSpace())
|
||||
{
|
||||
return requestBuilder;
|
||||
}
|
||||
|
||||
if (long.TryParse(deviceId, out integerId))
|
||||
if (long.TryParse(deviceId, out var integerId))
|
||||
{
|
||||
requestBuilder.AddFormParameter("device_id", integerId);
|
||||
}
|
||||
|
|
|
@ -459,10 +459,8 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
public static string CleanMovieTitle(this string title)
|
||||
{
|
||||
long number = 0;
|
||||
|
||||
// If Title only contains numbers return it as is.
|
||||
if (long.TryParse(title, out number))
|
||||
if (long.TryParse(title, out _))
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
@ -550,9 +548,8 @@ namespace NzbDrone.Core.Parser
|
|||
if (matches.Count != 0)
|
||||
{
|
||||
var group = matches.OfType<Match>().Last().Groups["releasegroup"].Value;
|
||||
int groupIsNumeric;
|
||||
|
||||
if (int.TryParse(group, out groupIsNumeric))
|
||||
if (int.TryParse(group, out _))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Parser.RomanNumerals
|
||||
|
@ -52,9 +52,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
/// <param name="romanNumeral">The roman numeral.</param>
|
||||
public RomanNumeral(string romanNumeral)
|
||||
{
|
||||
int value;
|
||||
|
||||
if (TryParse(romanNumeral, out value))
|
||||
if (TryParse(romanNumeral, out var value))
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
@ -312,10 +310,9 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
}
|
||||
else if (obj is string)
|
||||
{
|
||||
int value;
|
||||
var numeral = obj as string;
|
||||
|
||||
if (TryParse(numeral, out value))
|
||||
if (TryParse(numeral, out var value))
|
||||
{
|
||||
return _value.CompareTo(value);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -28,8 +28,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
_simpleArabicNumeralMappings = new Dictionary<SimpleArabicNumeral, SimpleRomanNumeral>();
|
||||
foreach (int arabicNumeral in Enumerable.Range(1, DICTIONARY_PREPOPULATION_SIZE + 1))
|
||||
{
|
||||
string romanNumeralAsString, arabicNumeralAsString;
|
||||
GenerateRomanNumerals(arabicNumeral, out romanNumeralAsString, out arabicNumeralAsString);
|
||||
GenerateRomanNumerals(arabicNumeral, out var romanNumeralAsString, out var arabicNumeralAsString);
|
||||
ArabicRomanNumeral arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeralAsString);
|
||||
_arabicRomanNumeralsMapping.Add(arm);
|
||||
|
||||
|
@ -51,9 +50,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
HashSet<ArabicRomanNumeral> additionalArabicRomanNumerals = new HashSet<ArabicRomanNumeral>();
|
||||
foreach (int arabicNumeral in Enumerable.Range(offset, length))
|
||||
{
|
||||
string romanNumeral;
|
||||
string arabicNumeralAsString;
|
||||
GenerateRomanNumerals(arabicNumeral, out romanNumeral, out arabicNumeralAsString);
|
||||
GenerateRomanNumerals(arabicNumeral, out var romanNumeral, out var arabicNumeralAsString);
|
||||
ArabicRomanNumeral arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeral);
|
||||
additionalArabicRomanNumerals.Add(arm);
|
||||
}
|
||||
|
@ -129,9 +126,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
Dictionary<SimpleArabicNumeral, SimpleRomanNumeral> moreNumerals = new Dictionary<SimpleArabicNumeral, SimpleRomanNumeral>();
|
||||
foreach (int arabicNumeral in Enumerable.Range(offset, length))
|
||||
{
|
||||
string romanNumeral;
|
||||
string arabicNumeralAsString;
|
||||
GenerateRomanNumerals(arabicNumeral, out romanNumeral, out arabicNumeralAsString);
|
||||
GenerateRomanNumerals(arabicNumeral, out var romanNumeral, out _);
|
||||
SimpleArabicNumeral san = new SimpleArabicNumeral(arabicNumeral);
|
||||
SimpleRomanNumeral srn = new SimpleRomanNumeral(romanNumeral);
|
||||
moreNumerals.Add(san, srn);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System;
|
||||
using NzbDrone.Common.Cache;
|
||||
|
||||
namespace NzbDrone.Core.Restrictions
|
||||
|
@ -30,8 +29,7 @@ namespace NzbDrone.Core.Restrictions
|
|||
|
||||
private Predicate<string> CreateMatcherInternal(string term)
|
||||
{
|
||||
Regex regex;
|
||||
if (PerlRegexFactory.TryCreateRegex(term, out regex))
|
||||
if (PerlRegexFactory.TryCreateRegex(term, out var regex))
|
||||
{
|
||||
return regex.IsMatch;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,7 @@ namespace NzbDrone.Mono.Test.DiskProviderTests
|
|||
protected void SetWritePermissionsInternal(string path, bool writable, bool setgid)
|
||||
{
|
||||
// Remove Write permissions, we're still owner so we can clean it up, but we'll have to do that explicitly.
|
||||
Stat stat;
|
||||
Syscall.stat(path, out stat);
|
||||
Syscall.stat(path, out var stat);
|
||||
FilePermissions mode = stat.st_mode;
|
||||
|
||||
if (writable)
|
||||
|
|
|
@ -474,9 +474,7 @@ namespace NzbDrone.Mono.Disk
|
|||
return UNCHANGED_ID;
|
||||
}
|
||||
|
||||
uint userId;
|
||||
|
||||
if (uint.TryParse(user, out userId))
|
||||
if (uint.TryParse(user, out var userId))
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
@ -498,9 +496,7 @@ namespace NzbDrone.Mono.Disk
|
|||
return UNCHANGED_ID;
|
||||
}
|
||||
|
||||
uint groupId;
|
||||
|
||||
if (uint.TryParse(group, out groupId))
|
||||
if (uint.TryParse(group, out var groupId))
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
|
|
|
@ -83,9 +83,7 @@ namespace NzbDrone.Mono.Disk
|
|||
|
||||
private bool TryFollowFirstSymbolicLink(ref string path)
|
||||
{
|
||||
string[] dirs;
|
||||
int lastIndex;
|
||||
GetPathComponents(path, out dirs, out lastIndex);
|
||||
GetPathComponents(path, out var dirs, out var lastIndex);
|
||||
|
||||
if (lastIndex == 0)
|
||||
{
|
||||
|
|
|
@ -23,8 +23,7 @@ namespace NzbDrone.Test.Common
|
|||
{
|
||||
LogManager.Configuration = new LoggingConfiguration();
|
||||
|
||||
var logOutput = TestLogOutput.Console;
|
||||
Enum.TryParse<TestLogOutput>(Environment.GetEnvironmentVariable("RADARR_TESTS_LOG_OUTPUT"), out logOutput);
|
||||
Enum.TryParse<TestLogOutput>(Environment.GetEnvironmentVariable("RADARR_TESTS_LOG_OUTPUT"), out var logOutput);
|
||||
|
||||
RegisterSentryLogger();
|
||||
|
||||
|
|
|
@ -99,8 +99,7 @@ namespace NzbDrone.Update
|
|||
|
||||
private int ParseProcessId(string arg)
|
||||
{
|
||||
int id;
|
||||
if (!int.TryParse(arg, out id) || id <= 0)
|
||||
if (!int.TryParse(arg, out var id) || id <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("arg", "Invalid process ID");
|
||||
}
|
||||
|
|
|
@ -92,8 +92,7 @@ namespace NzbDrone.Windows.Disk
|
|||
PropagationFlags.InheritOnly,
|
||||
controlType);
|
||||
|
||||
bool modified;
|
||||
directorySecurity.ModifyAccessRule(AccessControlModification.Add, accessRule, out modified);
|
||||
directorySecurity.ModifyAccessRule(AccessControlModification.Add, accessRule, out var modified);
|
||||
|
||||
if (modified)
|
||||
{
|
||||
|
@ -142,11 +141,7 @@ namespace NzbDrone.Windows.Disk
|
|||
folderName += '\\';
|
||||
}
|
||||
|
||||
ulong free = 0;
|
||||
ulong dummy1 = 0;
|
||||
ulong dummy2 = 0;
|
||||
|
||||
if (GetDiskFreeSpaceEx(folderName, out free, out dummy1, out dummy2))
|
||||
if (GetDiskFreeSpaceEx(folderName, out var free, out var dummy1, out var dummy2))
|
||||
{
|
||||
return (long)free;
|
||||
}
|
||||
|
@ -163,11 +158,7 @@ namespace NzbDrone.Windows.Disk
|
|||
folderName += '\\';
|
||||
}
|
||||
|
||||
ulong total = 0;
|
||||
ulong dummy1 = 0;
|
||||
ulong dummy2 = 0;
|
||||
|
||||
if (GetDiskFreeSpaceEx(folderName, out dummy1, out total, out dummy2))
|
||||
if (GetDiskFreeSpaceEx(folderName, out var dummy1, out var total, out var dummy2))
|
||||
{
|
||||
return (long)total;
|
||||
}
|
||||
|
|
|
@ -67,8 +67,7 @@ namespace Radarr.Http.ClientSchema
|
|||
{
|
||||
lock (_mappings)
|
||||
{
|
||||
FieldMapping[] result;
|
||||
if (!_mappings.TryGetValue(type, out result))
|
||||
if (!_mappings.TryGetValue(type, out var result))
|
||||
{
|
||||
result = GetFieldMapping(type, "", v => v);
|
||||
|
||||
|
|
Loading…
Reference in New Issue