mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 22:07:32 -04:00
Use 'var' instead of explicit type
(cherry picked from commit 12374f7f0038e5b25548f5ab3f71122410832393)
This commit is contained in:
parent
0509335387
commit
360827708f
61 changed files with 128 additions and 128 deletions
|
@ -67,7 +67,7 @@ namespace NzbDrone.Automation.Test
|
|||
{
|
||||
try
|
||||
{
|
||||
Screenshot image = ((ITakesScreenshot)driver).GetScreenshot();
|
||||
var image = ((ITakesScreenshot)driver).GetScreenshot();
|
||||
image.SaveAsFile($"./{name}_test_screenshot.png", ScreenshotImageFormat.Png);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace NzbDrone.Automation.Test.PageModel
|
|||
{
|
||||
try
|
||||
{
|
||||
IWebElement element = d.FindElement(By.ClassName("followingBalls"));
|
||||
var element = d.FindElement(By.ClassName("followingBalls"));
|
||||
return !element.Displayed;
|
||||
}
|
||||
catch (NoSuchElementException)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
|
@ -65,9 +65,9 @@ namespace NzbDrone.Common.Test.CacheTests
|
|||
[Test]
|
||||
public void should_store_null()
|
||||
{
|
||||
int hitCount = 0;
|
||||
var hitCount = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
_cachedString.Get("key", () =>
|
||||
{
|
||||
|
@ -83,10 +83,10 @@ namespace NzbDrone.Common.Test.CacheTests
|
|||
[Platform(Exclude = "MacOsX")]
|
||||
public void should_honor_ttl()
|
||||
{
|
||||
int hitCount = 0;
|
||||
var hitCount = 0;
|
||||
_cachedString = new Cached<string>();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
_cachedString.Get("key",
|
||||
() =>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -142,7 +142,7 @@ namespace NzbDrone.Common.Test
|
|||
[Test]
|
||||
public void SaveDictionary_should_save_proper_value()
|
||||
{
|
||||
int port = 20555;
|
||||
var port = 20555;
|
||||
|
||||
var dic = Subject.GetConfigDictionary();
|
||||
dic["Port"] = 20555;
|
||||
|
@ -155,9 +155,9 @@ namespace NzbDrone.Common.Test
|
|||
[Test]
|
||||
public void SaveDictionary_should_only_save_specified_values()
|
||||
{
|
||||
int port = 20555;
|
||||
int origSslPort = 20551;
|
||||
int sslPort = 20552;
|
||||
var port = 20555;
|
||||
var origSslPort = 20551;
|
||||
var sslPort = 20552;
|
||||
|
||||
var dic = Subject.GetConfigDictionary();
|
||||
dic["Port"] = port;
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
|||
[Test]
|
||||
public void should_not_contain_recycling_bin_for_root_of_drive()
|
||||
{
|
||||
string root = @"C:\".AsOsAgnostic();
|
||||
var root = @"C:\".AsOsAgnostic();
|
||||
SetupFolders(root);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -55,7 +55,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
|||
[Test]
|
||||
public void should_not_contain_system_volume_information()
|
||||
{
|
||||
string root = @"C:\".AsOsAgnostic();
|
||||
var root = @"C:\".AsOsAgnostic();
|
||||
SetupFolders(root);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -68,7 +68,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
|||
[Test]
|
||||
public void should_not_contain_recycling_bin_or_system_volume_information_for_root_of_drive()
|
||||
{
|
||||
string root = @"C:\".AsOsAgnostic();
|
||||
var root = @"C:\".AsOsAgnostic();
|
||||
SetupFolders(root);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
|
|
@ -788,7 +788,7 @@ namespace NzbDrone.Common.Test.Http
|
|||
try
|
||||
{
|
||||
// the date is bad in the below - should be 13-Jul-2026
|
||||
string malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
|
||||
var malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
|
||||
var requestSet = new HttpRequestBuilder($"https://{_httpBinHost}/response-headers")
|
||||
.AddQueryParam("Set-Cookie", malformedCookie)
|
||||
.Build();
|
||||
|
@ -822,7 +822,7 @@ namespace NzbDrone.Common.Test.Http
|
|||
{
|
||||
try
|
||||
{
|
||||
string url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
|
||||
var url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
|
||||
|
||||
var requestSet = new HttpRequest(url);
|
||||
requestSet.AllowAutoRedirect = false;
|
||||
|
|
|
@ -74,17 +74,17 @@ namespace NzbDrone.Common
|
|||
continue; // Ignore directories
|
||||
}
|
||||
|
||||
string entryFileName = zipEntry.Name;
|
||||
var entryFileName = zipEntry.Name;
|
||||
|
||||
// to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
|
||||
// Optionally match entrynames against a selection list here to skip as desired.
|
||||
// The unpacked length is available in the zipEntry.Size property.
|
||||
byte[] buffer = new byte[4096]; // 4K is optimum
|
||||
Stream zipStream = zipFile.GetInputStream(zipEntry);
|
||||
var buffer = new byte[4096]; // 4K is optimum
|
||||
var zipStream = zipFile.GetInputStream(zipEntry);
|
||||
|
||||
// Manipulate the output filename here as desired.
|
||||
string fullZipToPath = Path.Combine(destination, entryFileName);
|
||||
string directoryName = Path.GetDirectoryName(fullZipToPath);
|
||||
var fullZipToPath = Path.Combine(destination, entryFileName);
|
||||
var directoryName = Path.GetDirectoryName(fullZipToPath);
|
||||
if (directoryName.Length > 0)
|
||||
{
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
@ -93,7 +93,7 @@ namespace NzbDrone.Common
|
|||
// Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
|
||||
// of the file, but does not waste memory.
|
||||
// The "using" will close the stream even if an exception occurs.
|
||||
using (FileStream streamWriter = File.Create(fullZipToPath))
|
||||
using (var streamWriter = File.Create(fullZipToPath))
|
||||
{
|
||||
StreamUtils.Copy(zipStream, streamWriter, buffer);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ namespace NzbDrone.Common
|
|||
Stream inStream = File.OpenRead(compressedFile);
|
||||
Stream gzipStream = new GZipInputStream(inStream);
|
||||
|
||||
TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null);
|
||||
var tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null);
|
||||
tarArchive.ExtractContents(destination);
|
||||
tarArchive.Close();
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ namespace NzbDrone.Common.Disk
|
|||
|
||||
var stringComparison = (Kind == OsPathKind.Windows || other.Kind == OsPathKind.Windows) ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture;
|
||||
|
||||
for (int i = 0; i < leftFragments.Length; i++)
|
||||
for (var i = 0; i < leftFragments.Length; i++)
|
||||
{
|
||||
if (!string.Equals(leftFragments[i], rightFragments[i], stringComparison))
|
||||
{
|
||||
|
@ -372,12 +372,12 @@ namespace NzbDrone.Common.Disk
|
|||
|
||||
var newFragments = new List<string>();
|
||||
|
||||
for (int j = i; j < rightFragments.Length; j++)
|
||||
for (var j = i; j < rightFragments.Length; j++)
|
||||
{
|
||||
newFragments.Add("..");
|
||||
}
|
||||
|
||||
for (int j = i; j < leftFragments.Length; j++)
|
||||
for (var j = i; j < leftFragments.Length; j++)
|
||||
{
|
||||
newFragments.Add(leftFragments[j]);
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ namespace NzbDrone.Common.Extensions
|
|||
|
||||
public static bool IsValidDate(this string dateTime)
|
||||
{
|
||||
DateTime.TryParse(dateTime, out DateTime result);
|
||||
DateTime.TryParse(dateTime, out var result);
|
||||
|
||||
return !result.Equals(default(DateTime));
|
||||
}
|
||||
|
||||
public static bool IsFutureDate(this string dateTime)
|
||||
{
|
||||
DateTime.TryParse(dateTime, out DateTime result);
|
||||
DateTime.TryParse(dateTime, out var result);
|
||||
|
||||
return !result.Equals(default(DateTime)) && result.After(DateTime.Now);
|
||||
}
|
||||
|
|
|
@ -126,9 +126,9 @@ namespace NzbDrone.Common.Extensions
|
|||
|
||||
private static IEnumerable<T> InternalDropLast<T>(IEnumerable<T> source, int n)
|
||||
{
|
||||
Queue<T> buffer = new Queue<T>(n + 1);
|
||||
var buffer = new Queue<T>(n + 1);
|
||||
|
||||
foreach (T x in source)
|
||||
foreach (var x in source)
|
||||
{
|
||||
buffer.Enqueue(x);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace NzbDrone.Common.Extensions
|
|||
return text.Length * costDelete;
|
||||
}
|
||||
|
||||
int[] matrix = new int[other.Length + 1];
|
||||
var matrix = new int[other.Length + 1];
|
||||
|
||||
for (var i = 1; i < matrix.Length; i++)
|
||||
{
|
||||
|
@ -30,13 +30,13 @@ namespace NzbDrone.Common.Extensions
|
|||
|
||||
for (var i = 0; i < text.Length; i++)
|
||||
{
|
||||
int topLeft = matrix[0];
|
||||
var topLeft = matrix[0];
|
||||
matrix[0] = matrix[0] + costDelete;
|
||||
|
||||
for (var j = 0; j < other.Length; j++)
|
||||
{
|
||||
int top = matrix[j];
|
||||
int left = matrix[j + 1];
|
||||
var top = matrix[j];
|
||||
var left = matrix[j + 1];
|
||||
|
||||
var sumIns = top + costInsert;
|
||||
var sumDel = left + costDelete;
|
||||
|
|
|
@ -198,13 +198,13 @@ namespace NzbDrone.Common.Extensions
|
|||
|
||||
public static string CleanFileName(this string name)
|
||||
{
|
||||
string result = name;
|
||||
var result = name;
|
||||
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
|
||||
string[] goodCharacters = { "+", "+", "", "", "!", "-", "-", "", "" };
|
||||
|
||||
result = result.Replace(": ", " - ");
|
||||
|
||||
for (int i = 0; i < badCharacters.Length; i++)
|
||||
for (var i = 0; i < badCharacters.Length; i++)
|
||||
{
|
||||
result = result.Replace(badCharacters[i], goodCharacters[i]);
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ namespace NzbDrone.Common
|
|||
{
|
||||
public static string CalculateCrc(string input)
|
||||
{
|
||||
uint mCrc = 0xffffffff;
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(input);
|
||||
foreach (byte myByte in bytes)
|
||||
var mCrc = 0xffffffff;
|
||||
var bytes = Encoding.UTF8.GetBytes(input);
|
||||
foreach (var myByte in bytes)
|
||||
{
|
||||
mCrc ^= (uint)myByte << 24;
|
||||
for (var i = 0; i < 8; i++)
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace NzbDrone.Common.Http.Dispatchers
|
|||
|
||||
headers.Add(responseMessage.Content.Headers.ToNameValueCollection());
|
||||
|
||||
CookieContainer responseCookies = new CookieContainer();
|
||||
var responseCookies = new CookieContainer();
|
||||
|
||||
if (responseMessage.Headers.TryGetValues("Set-Cookie", out var cookieHeaders))
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Common.Http
|
|||
|
||||
public HttpUri(string scheme, string host, int? port, string path, string query, string fragment)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
|
||||
if (scheme.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace NzbDrone.Common.Http.Proxy
|
|||
if (!string.IsNullOrWhiteSpace(BypassFilter))
|
||||
{
|
||||
var hostlist = BypassFilter.Split(',');
|
||||
for (int i = 0; i < hostlist.Length; i++)
|
||||
for (var i = 0; i < hostlist.Length; i++)
|
||||
{
|
||||
if (hostlist[i].StartsWith("*"))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Common.Instrumentation
|
||||
|
@ -16,7 +16,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
}
|
||||
}
|
||||
|
||||
foreach (JToken token in json)
|
||||
foreach (var token in json)
|
||||
{
|
||||
Visit(token);
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
|
||||
private static void RegisterDebugger()
|
||||
{
|
||||
DebuggerTarget target = new DebuggerTarget();
|
||||
var target = new DebuggerTarget();
|
||||
target.Name = "debuggerLogger";
|
||||
target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NzbDrone.Common.Serializer
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Common.Serializer
|
|||
|
||||
public virtual void Visit(JArray json)
|
||||
{
|
||||
foreach (JToken token in json)
|
||||
foreach (var token in json)
|
||||
{
|
||||
Visit(token);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace NzbDrone.Common.Serializer
|
|||
|
||||
public virtual void Visit(JObject json)
|
||||
{
|
||||
foreach (JProperty property in json.Properties())
|
||||
foreach (var property in json.Properties())
|
||||
{
|
||||
Visit(property);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace NzbDrone.Common.Serializer
|
|||
var enumText = value.ToString();
|
||||
var builder = new StringBuilder(enumText.Length + 4);
|
||||
builder.Append(char.ToLower(enumText[0]));
|
||||
for (int i = 1; i < enumText.Length; i++)
|
||||
for (var i = 1; i < enumText.Length; i++)
|
||||
{
|
||||
if (char.IsUpper(enumText[i]))
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Common.Serializer
|
|||
{
|
||||
try
|
||||
{
|
||||
Version v = new Version(reader.GetString());
|
||||
var v = new Version(reader.GetString());
|
||||
return v;
|
||||
}
|
||||
catch (Exception)
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace NzbDrone.Common.TPL
|
|||
/// <returns>An enumerable of the tasks currently scheduled.</returns>
|
||||
protected sealed override IEnumerable<Task> GetScheduledTasks()
|
||||
{
|
||||
bool lockTaken = false;
|
||||
var lockTaken = false;
|
||||
try
|
||||
{
|
||||
Monitor.TryEnter(_tasks, ref lockTaken);
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace NzbDrone.Console
|
|||
}
|
||||
|
||||
System.Console.WriteLine("Non-recoverable failure, waiting for user intervention...");
|
||||
for (int i = 0; i < 3600; i++)
|
||||
for (var i = 0; i < 3600; i++)
|
||||
{
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
if (!System.Console.IsInputRedirected && System.Console.KeyAvailable)
|
||||
|
|
|
@ -197,7 +197,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
|
||||
Subject.SetFields(_basicList, x => x.Interval);
|
||||
|
||||
for (int i = 0; i < _basicList.Count; i++)
|
||||
for (var i = 0; i < _basicList.Count; i++)
|
||||
{
|
||||
_basicList[i].LastExecution = executionBackup[i];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
|
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test
|
|||
[Test]
|
||||
public void ToBestDateTime_DayOfWeek()
|
||||
{
|
||||
for (int i = 2; i < 7; i++)
|
||||
for (var i = 2; i < 7; i++)
|
||||
{
|
||||
var dateTime = DateTime.Today.AddDays(i);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.IndexerTests.PTPTests
|
|||
{
|
||||
var authResponse = new PassThePopcornAuthResponse { Result = "Ok" };
|
||||
|
||||
System.IO.StringWriter authStream = new System.IO.StringWriter();
|
||||
var authStream = new System.IO.StringWriter();
|
||||
Json.Serialize(authResponse, authStream);
|
||||
var responseJson = ReadAllText(fileName);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|||
public void write_long_log()
|
||||
{
|
||||
var message = string.Empty;
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
message += Guid.NewGuid();
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ namespace NzbDrone.Core.Configuration
|
|||
{
|
||||
const string defaultValue = "*";
|
||||
|
||||
string bindAddress = GetValue("BindAddress", defaultValue);
|
||||
var bindAddress = GetValue("BindAddress", defaultValue);
|
||||
if (string.IsNullOrWhiteSpace(bindAddress))
|
||||
{
|
||||
return defaultValue;
|
||||
|
|
|
@ -196,7 +196,7 @@ namespace NzbDrone.Core.Datastore
|
|||
|
||||
using (var conn = _database.OpenConnection())
|
||||
{
|
||||
using (IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
|
||||
using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
|
||||
{
|
||||
foreach (var model in models)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Datastore.Converters
|
|||
}
|
||||
|
||||
string contract;
|
||||
using (JsonDocument body = JsonDocument.Parse(stringValue))
|
||||
using (var body = JsonDocument.Parse(stringValue))
|
||||
{
|
||||
contract = body.RootElement.GetProperty("name").GetString();
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||
|
||||
public virtual IList<TableDefinition> ReadDbSchema()
|
||||
{
|
||||
IList<TableDefinition> tables = ReadTables();
|
||||
var tables = ReadTables();
|
||||
foreach (var table in tables)
|
||||
{
|
||||
table.Indexes = ReadIndexes(table.SchemaName, table.Name);
|
||||
|
@ -264,7 +264,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||
protected virtual IList<IndexDefinition> ReadIndexes(string schemaName, string tableName)
|
||||
{
|
||||
var sqlCommand = string.Format(@"SELECT type, name, sql FROM sqlite_master WHERE tbl_name = '{0}' AND type = 'index' AND name NOT LIKE 'sqlite_auto%';", tableName);
|
||||
DataTable table = Read(sqlCommand).Tables[0];
|
||||
var table = Read(sqlCommand).Tables[0];
|
||||
|
||||
IList<IndexDefinition> indexes = new List<IndexDefinition>();
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
|
|||
|
||||
private JsonRpcRequestBuilder BuildRequest(DelugeSettings settings)
|
||||
{
|
||||
string url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
|
||||
var url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
|
||||
|
||||
var requestBuilder = new JsonRpcRequestBuilder(url);
|
||||
requestBuilder.LogResponseContent = true;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace NzbDrone.Core.Download.Clients.FreeboxDownload
|
||||
namespace NzbDrone.Core.Download.Clients.FreeboxDownload
|
||||
{
|
||||
public static class EncodingForBase64
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
byte[] textAsBytes = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
var textAsBytes = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
return System.Convert.ToBase64String(textAsBytes);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
byte[] textAsBytes = System.Convert.FromBase64String(encodedText);
|
||||
var textAsBytes = System.Convert.FromBase64String(encodedText);
|
||||
return System.Text.Encoding.UTF8.GetString(textAsBytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
|||
|
||||
protected IEnumerable<NzbgetCategory> GetCategories(Dictionary<string, string> config)
|
||||
{
|
||||
for (int i = 1; i < 100; i++)
|
||||
for (var i = 1; i < 100; i++)
|
||||
{
|
||||
var name = config.GetValueOrDefault("Category" + i + ".Name");
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
|||
return null;
|
||||
}
|
||||
|
||||
Dictionary<string, QBittorrentLabel> labels = Proxy.GetLabels(Settings);
|
||||
var labels = Proxy.GetLabels(Settings);
|
||||
|
||||
foreach (var category in Categories)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
|
|||
var stringArray = (string[])value;
|
||||
writer.WriteStartArray();
|
||||
|
||||
for (int i = 0; i < stringArray.Length; i++)
|
||||
for (var i = 0; i < stringArray.Length; i++)
|
||||
{
|
||||
writer.WriteValue(stringArray[i]);
|
||||
}
|
||||
|
|
|
@ -32,13 +32,13 @@ namespace NzbDrone.Core.Download.Extensions
|
|||
public static long ElementAsLong(this XElement element, XName name)
|
||||
{
|
||||
var el = element.Element(name);
|
||||
return long.TryParse(el?.Value, out long value) ? value : default;
|
||||
return long.TryParse(el?.Value, out var value) ? value : default;
|
||||
}
|
||||
|
||||
public static int ElementAsInt(this XElement element, XName name)
|
||||
{
|
||||
var el = element.Element(name);
|
||||
return int.TryParse(el?.Value, out int value) ? value : default(int);
|
||||
return int.TryParse(el?.Value, out var value) ? value : default(int);
|
||||
}
|
||||
|
||||
public static int GetIntResponse(this XDocument document)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -95,17 +95,17 @@ namespace NzbDrone.Core
|
|||
}
|
||||
|
||||
var cs = s.ToCharArray();
|
||||
int length = 0;
|
||||
int i = 0;
|
||||
var length = 0;
|
||||
var i = 0;
|
||||
while (i < cs.Length)
|
||||
{
|
||||
int charSize = 1;
|
||||
var charSize = 1;
|
||||
if (i < (cs.Length - 1) && char.IsSurrogate(cs[i]))
|
||||
{
|
||||
charSize = 2;
|
||||
}
|
||||
|
||||
int byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize);
|
||||
var byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize);
|
||||
if ((byteSize + length) <= maxLength)
|
||||
{
|
||||
i = i + charSize;
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace NzbDrone.Core.IndexerStats
|
|||
var sortedEvents = indexer.OrderBy(v => v.Date)
|
||||
.ThenBy(v => v.Id)
|
||||
.ToArray();
|
||||
int temp = 0;
|
||||
var temp = 0;
|
||||
|
||||
var elapsedTimeEvents = sortedEvents.Where(h => int.TryParse(h.Data.GetValueOrDefault("elapsedTime"), out temp))
|
||||
.Select(h => temp);
|
||||
|
|
|
@ -293,7 +293,7 @@ namespace NzbDrone.Core.IndexerVersions
|
|||
|
||||
_httpClient.DownloadFile($"https://indexers.prowlarr.com/{DEFINITION_BRANCH}/{DEFINITION_VERSION}/package.zip", saveFile);
|
||||
|
||||
using (ZipArchive archive = ZipFile.OpenRead(saveFile))
|
||||
using (var archive = ZipFile.OpenRead(saveFile))
|
||||
{
|
||||
archive.ExtractToDirectory(definitionsFolder, true);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
|
|||
throw new IndexerException(indexerResponse, "Indexer API returned an internal server error");
|
||||
}
|
||||
|
||||
JsonRpcResponse<BroadcastheNetTorrents> jsonResponse = new HttpResponse<JsonRpcResponse<BroadcastheNetTorrents>>(indexerHttpResponse).Resource;
|
||||
var jsonResponse = new HttpResponse<JsonRpcResponse<BroadcastheNetTorrents>>(indexerHttpResponse).Resource;
|
||||
|
||||
if (jsonResponse.Error != null || jsonResponse.Result == null)
|
||||
{
|
||||
|
|
|
@ -276,7 +276,7 @@ namespace NzbDrone.Core.Indexers
|
|||
|
||||
var pageableRequestChain = pageableRequestChainSelector(generator);
|
||||
|
||||
for (int i = 0; i < pageableRequestChain.Tiers; i++)
|
||||
for (var i = 0; i < pageableRequestChain.Tiers; i++)
|
||||
{
|
||||
var pageableRequests = pageableRequestChain.GetTier(i);
|
||||
|
||||
|
|
|
@ -129,8 +129,8 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
var envLimit = Environment.GetEnvironmentVariable("THREAD_LIMIT") ?? $"{THREAD_LIMIT}";
|
||||
int threadLimit = THREAD_LIMIT;
|
||||
if (int.TryParse(envLimit, out int parsedLimit))
|
||||
var threadLimit = THREAD_LIMIT;
|
||||
if (int.TryParse(envLimit, out var parsedLimit))
|
||||
{
|
||||
threadLimit = parsedLimit;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||
|
||||
_logger.Info("Starting {} threads for tasks.", threadLimit);
|
||||
|
||||
for (int i = 0; i < threadLimit + 1; i++)
|
||||
for (var i = 0; i < threadLimit + 1; i++)
|
||||
{
|
||||
var thread = new Thread(ExecuteCommands);
|
||||
thread.Start();
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||
|
||||
public CommandModel Push(string commandName, DateTime? lastExecutionTime, DateTime? lastStartTime, CommandPriority priority = CommandPriority.Normal, CommandTrigger trigger = CommandTrigger.Unspecified)
|
||||
{
|
||||
dynamic command = GetCommand(commandName);
|
||||
var command = GetCommand(commandName);
|
||||
command.LastExecutionTime = lastExecutionTime;
|
||||
command.LastStartTime = lastStartTime;
|
||||
command.Trigger = trigger;
|
||||
|
|
|
@ -109,7 +109,7 @@ namespace NzbDrone.Core.Parser
|
|||
DateTimeRoutines.DateTimeFormat.USDate;
|
||||
|
||||
if (DateTimeRoutines.TryParseDateOrTime(
|
||||
str, dtFormat, out DateTimeRoutines.ParsedDateTime dt))
|
||||
str, dtFormat, out var dt))
|
||||
{
|
||||
return dt.DateTime;
|
||||
}
|
||||
|
|
|
@ -95,9 +95,9 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
}
|
||||
|
||||
text = text.ToUpper();
|
||||
int len = 0;
|
||||
var len = 0;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
if (text.StartsWith(Thousands[i]))
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
len = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
for (var i = 0; i < 9; i++)
|
||||
{
|
||||
if (text.StartsWith(Hundreds[i]))
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
len = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
for (var i = 0; i < 9; i++)
|
||||
{
|
||||
if (text.StartsWith(Tens[i]))
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
len = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
for (var i = 0; i < 9; i++)
|
||||
{
|
||||
if (text.StartsWith(Units[i]))
|
||||
{
|
||||
|
|
|
@ -26,32 +26,32 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
|
||||
_arabicRomanNumeralsMapping = new HashSet<ArabicRomanNumeral>();
|
||||
_simpleArabicNumeralMappings = new Dictionary<SimpleArabicNumeral, SimpleRomanNumeral>();
|
||||
foreach (int arabicNumeral in Enumerable.Range(1, DICTIONARY_PREPOPULATION_SIZE + 1))
|
||||
foreach (var arabicNumeral in Enumerable.Range(1, DICTIONARY_PREPOPULATION_SIZE + 1))
|
||||
{
|
||||
GenerateRomanNumerals(arabicNumeral, out var romanNumeralAsString, out var arabicNumeralAsString);
|
||||
ArabicRomanNumeral arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeralAsString);
|
||||
var arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeralAsString);
|
||||
_arabicRomanNumeralsMapping.Add(arm);
|
||||
|
||||
SimpleArabicNumeral sam = new SimpleArabicNumeral(arabicNumeral);
|
||||
SimpleRomanNumeral srm = new SimpleRomanNumeral(romanNumeralAsString);
|
||||
var sam = new SimpleArabicNumeral(arabicNumeral);
|
||||
var srm = new SimpleRomanNumeral(romanNumeralAsString);
|
||||
_simpleArabicNumeralMappings.Add(sam, srm);
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateRomanNumerals(int arabicNumeral, out string romanNumeral, out string arabicNumeralAsString)
|
||||
{
|
||||
RomanNumeral romanNumeralObject = new RomanNumeral(arabicNumeral);
|
||||
var romanNumeralObject = new RomanNumeral(arabicNumeral);
|
||||
romanNumeral = romanNumeralObject.ToRomanNumeral();
|
||||
arabicNumeralAsString = Convert.ToString(arabicNumeral);
|
||||
}
|
||||
|
||||
private static HashSet<ArabicRomanNumeral> GenerateAdditionalMappings(int offset, int length)
|
||||
{
|
||||
HashSet<ArabicRomanNumeral> additionalArabicRomanNumerals = new HashSet<ArabicRomanNumeral>();
|
||||
foreach (int arabicNumeral in Enumerable.Range(offset, length))
|
||||
var additionalArabicRomanNumerals = new HashSet<ArabicRomanNumeral>();
|
||||
foreach (var arabicNumeral in Enumerable.Range(offset, length))
|
||||
{
|
||||
GenerateRomanNumerals(arabicNumeral, out var romanNumeral, out var arabicNumeralAsString);
|
||||
ArabicRomanNumeral arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeral);
|
||||
var arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeral);
|
||||
additionalArabicRomanNumerals.Add(arm);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
return new HashSet<ArabicRomanNumeral>(_arabicRomanNumeralsMapping.Take(upToArabicNumber));
|
||||
}
|
||||
|
||||
HashSet<ArabicRomanNumeral> largerMapping = GenerateAdditionalMappings(DICTIONARY_PREPOPULATION_SIZE + 1, upToArabicNumber);
|
||||
var largerMapping = GenerateAdditionalMappings(DICTIONARY_PREPOPULATION_SIZE + 1, upToArabicNumber);
|
||||
_arabicRomanNumeralsMapping = (HashSet<ArabicRomanNumeral>)_arabicRomanNumeralsMapping.Union(largerMapping);
|
||||
}
|
||||
|
||||
|
@ -123,12 +123,12 @@ namespace NzbDrone.Core.Parser.RomanNumerals
|
|||
private static Dictionary<SimpleArabicNumeral, SimpleRomanNumeral> GenerateAdditionalSimpleNumerals(int offset,
|
||||
int length)
|
||||
{
|
||||
Dictionary<SimpleArabicNumeral, SimpleRomanNumeral> moreNumerals = new Dictionary<SimpleArabicNumeral, SimpleRomanNumeral>();
|
||||
foreach (int arabicNumeral in Enumerable.Range(offset, length))
|
||||
var moreNumerals = new Dictionary<SimpleArabicNumeral, SimpleRomanNumeral>();
|
||||
foreach (var arabicNumeral in Enumerable.Range(offset, length))
|
||||
{
|
||||
GenerateRomanNumerals(arabicNumeral, out var romanNumeral, out _);
|
||||
SimpleArabicNumeral san = new SimpleArabicNumeral(arabicNumeral);
|
||||
SimpleRomanNumeral srn = new SimpleRomanNumeral(romanNumeral);
|
||||
var san = new SimpleArabicNumeral(arabicNumeral);
|
||||
var srn = new SimpleRomanNumeral(romanNumeral);
|
||||
moreNumerals.Add(san, srn);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
public static string CleanFileName(string name, bool replace = true)
|
||||
{
|
||||
string result = name;
|
||||
var result = name;
|
||||
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
|
||||
string[] goodCharacters = { "+", "+", "", "", "!", "-", "-", "", "" };
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Parser
|
|||
result = result.Replace(": ", " - ");
|
||||
}
|
||||
|
||||
for (int i = 0; i < badCharacters.Length; i++)
|
||||
for (var i = 0; i < badCharacters.Length; i++)
|
||||
{
|
||||
result = result.Replace(badCharacters[i], replace ? goodCharacters[i] : string.Empty);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace NzbDrone.Mono.Test.DiskProviderTests
|
|||
{
|
||||
// Remove Write permissions, we're still owner so we can clean it up, but we'll have to do that explicitly.
|
||||
Syscall.stat(path, out var stat);
|
||||
FilePermissions mode = stat.st_mode;
|
||||
var mode = stat.st_mode;
|
||||
|
||||
if (writable)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
|
|||
var fullName = "";
|
||||
var version = "";
|
||||
|
||||
bool success = false;
|
||||
var success = false;
|
||||
|
||||
foreach (var releaseFile in releaseFiles)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace NzbDrone.Test.Common
|
|||
|
||||
public int Start()
|
||||
{
|
||||
int threadId = Environment.CurrentManagedThreadId;
|
||||
var threadId = Environment.CurrentManagedThreadId;
|
||||
lock (_mutex)
|
||||
{
|
||||
_threads[threadId] = 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
@ -44,10 +44,10 @@ namespace NzbDrone.Test.Common
|
|||
|
||||
private static string GetLogsString(IEnumerable<LogEventInfo> logs)
|
||||
{
|
||||
string errors = "";
|
||||
var errors = "";
|
||||
foreach (var log in logs)
|
||||
{
|
||||
string exception = "";
|
||||
var exception = "";
|
||||
if (log.Exception != null)
|
||||
{
|
||||
exception = string.Format("[{0}: {1}]", log.Exception.GetType(), log.Exception.Message);
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Update.Test
|
|||
[Test]
|
||||
public void should_start_service_if_app_type_was_serivce()
|
||||
{
|
||||
string targetFolder = "c:\\Prowlarr\\".AsOsAgnostic();
|
||||
var targetFolder = "c:\\Prowlarr\\".AsOsAgnostic();
|
||||
|
||||
Subject.Start(AppType.Service, targetFolder);
|
||||
|
||||
|
@ -27,8 +27,8 @@ namespace NzbDrone.Update.Test
|
|||
[Test]
|
||||
public void should_start_console_if_app_type_was_service_but_start_failed_because_of_permissions()
|
||||
{
|
||||
string targetFolder = "c:\\Prowlarr\\".AsOsAgnostic();
|
||||
string targetProcess = "c:\\Prowlarr\\Prowlarr.Console".AsOsAgnostic().ProcessNameToExe();
|
||||
var targetFolder = "c:\\Prowlarr\\".AsOsAgnostic();
|
||||
var targetProcess = "c:\\Prowlarr\\Prowlarr.Console".AsOsAgnostic().ProcessNameToExe();
|
||||
|
||||
Mocker.GetMock<IServiceProvider>().Setup(c => c.Start(ServiceProvider.SERVICE_NAME)).Throws(new InvalidOperationException());
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ namespace NzbDrone.Update.UpdateEngine
|
|||
_terminateNzbDrone.Terminate(processId);
|
||||
|
||||
_logger.Info("Waiting for external auto-restart.");
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.IO;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Test.DiskTests;
|
||||
|
@ -19,7 +19,7 @@ namespace NzbDrone.Windows.Test.DiskProviderTests
|
|||
public void should_throw_if_drive_doesnt_exist()
|
||||
{
|
||||
// Find a drive that doesn't exist.
|
||||
for (char driveletter = 'Z'; driveletter > 'D'; driveletter--)
|
||||
for (var driveletter = 'Z'; driveletter > 'D'; driveletter--)
|
||||
{
|
||||
if (new DriveInfo(driveletter.ToString()).IsReady)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Prowlarr.Api.V1.Logs
|
|||
|
||||
var files = GetLogFiles().ToList();
|
||||
|
||||
for (int i = 0; i < files.Count; i++)
|
||||
for (var i = 0; i < files.Count; i++)
|
||||
{
|
||||
var file = files[i];
|
||||
var filename = Path.GetFileName(file);
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Prowlarr.Api.V1.Profiles.App
|
|||
[HttpGet]
|
||||
public AppProfileResource GetSchema()
|
||||
{
|
||||
AppSyncProfile qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
||||
var qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
||||
|
||||
return qualityProfile.ToResource();
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Prowlarr.Http.ClientSchema
|
|||
result = GetFieldMapping(type, "", v => v);
|
||||
|
||||
// Renumber al the field Orders since nested settings will have dupe Orders.
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
for (var i = 0; i < result.Length; i++)
|
||||
{
|
||||
result[i].Field.Order = i;
|
||||
}
|
||||
|
|
|
@ -139,13 +139,13 @@ namespace Prowlarr.Http.Extensions
|
|||
|
||||
public static string GetHostName(this HttpRequest request)
|
||||
{
|
||||
string ip = request.GetRemoteIP();
|
||||
var ip = request.GetRemoteIP();
|
||||
|
||||
try
|
||||
{
|
||||
IPAddress myIP = IPAddress.Parse(ip);
|
||||
IPHostEntry getIPHost = Dns.GetHostEntry(myIP);
|
||||
List<string> compName = getIPHost.HostName.ToString().Split('.').ToList();
|
||||
var myIP = IPAddress.Parse(ip);
|
||||
var getIPHost = Dns.GetHostEntry(myIP);
|
||||
var compName = getIPHost.HostName.ToString().Split('.').ToList();
|
||||
return compName.First();
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ServiceInstall
|
|||
|
||||
private static bool IsAnAdministrator()
|
||||
{
|
||||
WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
||||
var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ServiceUninstall
|
|||
|
||||
private static bool IsAnAdministrator()
|
||||
{
|
||||
WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
||||
var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue