qol: simplify and Tuple.Create()
This commit is contained in:
@@ -112,7 +112,7 @@ namespace Disco.Services
|
||||
// Obtain the Device Model with the in-scope DataContext
|
||||
// - Overhead acknowledged, but reasonable given the infrequency of occurrence
|
||||
deviceModel = DeviceModelsSet.FirstOrDefault(dm => dm.Manufacturer == Manufacturer && dm.Model == Model);
|
||||
return new Tuple<DeviceModel, bool>(deviceModel, true);
|
||||
return Tuple.Create(deviceModel, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace Disco.Services
|
||||
deviceModel.ModelType = ModelType;
|
||||
}
|
||||
|
||||
return new Tuple<DeviceModel, bool>(deviceModel, false);
|
||||
return Tuple.Create(deviceModel, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
Dictionary<string, Tuple<string, string>> addresses = new Dictionary<string, Tuple<string, string>>();
|
||||
|
||||
foreach (var result in results.OrderBy(r => r.Timestamp))
|
||||
addresses[((string)result.Arguments[1]).ToLower()] = new Tuple<string, string>((string)result.Arguments[4], (string)result.Arguments[5]);
|
||||
addresses[((string)result.Arguments[1]).ToLower()] = Tuple.Create((string)result.Arguments[4], (string)result.Arguments[5]);
|
||||
|
||||
Status.UpdateStatus(75, $"Importing {addresses.Count} details");
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Disco.Services.Documents
|
||||
byte[] dataBytes = new byte[numDataBytesInBlock];
|
||||
bits.toBytes(8 * dataBytesOffset, dataBytes, 0, numDataBytesInBlock);
|
||||
byte[] ecBytes = generateECBytes(dataBytes, numEcBytesInBlock);
|
||||
blocks.Add(new Tuple<byte[], byte[]>(dataBytes, ecBytes));
|
||||
blocks.Add(Tuple.Create(dataBytes, ecBytes));
|
||||
|
||||
maxNumDataBytes = Math.Max(maxNumDataBytes, numDataBytesInBlock);
|
||||
maxNumEcBytes = Math.Max(maxNumEcBytes, ecBytes.Length);
|
||||
|
||||
@@ -75,14 +75,14 @@ namespace Disco.Services.Expressions
|
||||
public Tuple<string, bool, object> Evaluate(object ExpressionContext, IDictionary Variables)
|
||||
{
|
||||
if (Count == 0)
|
||||
return new Tuple<string, bool, object>(string.Empty, false, null);
|
||||
return Tuple.Create(string.Empty, false, (object)null);
|
||||
|
||||
if (!IsDynamic)
|
||||
{
|
||||
if (Count != 1)
|
||||
throw new InvalidOperationException("Non-dynamic expressions should only have one part");
|
||||
if (this[0] is TextExpressionPart textPart)
|
||||
return new Tuple<string, bool, object>(textPart.RawSource, false, null);
|
||||
return Tuple.Create(textPart.RawSource, false, (object)null);
|
||||
else
|
||||
throw new InvalidOperationException("Non-dynamic expressions should have a single TextExpressionPart component");
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace Disco.Services.Expressions
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Tuple<string, bool, object>(resultValue.ToString(), resultError, resultObject);
|
||||
return Tuple.Create(resultValue.ToString(), resultError, resultObject);
|
||||
}
|
||||
public static Expression TokenizeSingleDynamic(string Name, string ExpressionSource, int Ordinal)
|
||||
{
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations
|
||||
}
|
||||
}
|
||||
|
||||
return new Tuple<int, int, double>(bestColumnCount, bestRowCount, bestItemRatio);
|
||||
return Tuple.Create(bestColumnCount, bestRowCount, bestItemRatio);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace Disco.Services
|
||||
public static Tuple<string, string> Status(this Job j)
|
||||
{
|
||||
var statusId = j.CalculateStatusId();
|
||||
return new Tuple<string, string>(statusId, JobStatusDescription(statusId, j));
|
||||
return Tuple.Create(statusId, JobStatusDescription(statusId, j));
|
||||
}
|
||||
|
||||
public static List<DocumentTemplate> AvailableDocumentTemplates(this Job j, DiscoDataContext Database, User User, DateTime TimeStamp)
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Disco.Services.Logging
|
||||
|
||||
private List<Tuple<string, DateTime>> RelevantLogFiles(DiscoDataContext Database)
|
||||
{
|
||||
List<Tuple<string, DateTime>> relevantFiles = new List<Tuple<string, DateTime>>();
|
||||
var relevantFiles = new List<Tuple<string, DateTime>>();
|
||||
var logDirectoryBase = LogContext.LogFileBasePath(Database);
|
||||
var logDirectoryBaseInfo = new DirectoryInfo(logDirectoryBase);
|
||||
var endDate = End.HasValue ? End.Value : DateTime.Now;
|
||||
@@ -92,7 +92,7 @@ namespace Disco.Services.Logging
|
||||
{
|
||||
var fileName = LogContext.LogFilePath(Database, queryDate, false);
|
||||
if (File.Exists(fileName))
|
||||
relevantFiles.Add(new Tuple<string, DateTime>(fileName, LogFileDate(fileName).Value));
|
||||
relevantFiles.Add(Tuple.Create(fileName, LogFileDate(fileName).Value));
|
||||
|
||||
queryDate = queryDate.AddDays(1);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ namespace Disco.Services.Logging
|
||||
{
|
||||
foreach (var logFile in logFiles)
|
||||
{
|
||||
relevantFiles.Add(new Tuple<string, DateTime>(logFile, LogFileDate(logFile).Value));
|
||||
relevantFiles.Add(Tuple.Create(logFile, LogFileDate(logFile).Value));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -130,7 +130,7 @@ namespace Disco.Services.Logging
|
||||
{
|
||||
if (fileNameDate.Value < endDate)
|
||||
{
|
||||
relevantFiles.Add(new Tuple<string, DateTime>(logFile, fileNameDate.Value));
|
||||
relevantFiles.Add(Tuple.Create(logFile, fileNameDate.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -519,7 +519,7 @@ namespace Disco.Services.Plugins
|
||||
var fileDateCheck = File.GetLastWriteTime(resourcePath);
|
||||
if (fileDateCheck == resourceHash.Item2)
|
||||
#endif
|
||||
return new Tuple<string, string>(resourcePath, resourceHash.Item1);
|
||||
return Tuple.Create(resourcePath, resourceHash.Item1);
|
||||
}
|
||||
|
||||
if (!File.Exists(resourcePath))
|
||||
@@ -532,12 +532,12 @@ namespace Disco.Services.Plugins
|
||||
using (SHA256 sha = SHA256.Create())
|
||||
{
|
||||
byte[] hash = sha.ComputeHash(fileBytes);
|
||||
resourceHash = new Tuple<string, DateTime>(HttpServerUtility.UrlTokenEncode(hash), fileDate);
|
||||
resourceHash = Tuple.Create(HttpServerUtility.UrlTokenEncode(hash), fileDate);
|
||||
}
|
||||
}
|
||||
WebResourceHashes[resourceKey] = resourceHash;
|
||||
|
||||
return new Tuple<string, string>(resourcePath, resourceHash.Item1);
|
||||
return Tuple.Create(resourcePath, resourceHash.Item1);
|
||||
}
|
||||
public string WebResourceUrl(string Resource)
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Disco.Services.Users
|
||||
{
|
||||
var cache = _Cache;
|
||||
|
||||
var record = new Tuple<User, AuthorizationToken, DateTime>(Record.Item1, Record.Item2, DateTime.Now.AddTicks(CacheTimeoutTicks));
|
||||
var record = Tuple.Create(Record.Item1, Record.Item2, DateTime.Now.AddTicks(CacheTimeoutTicks));
|
||||
if (cache.ContainsKey(UserId))
|
||||
{
|
||||
if (cache.TryGetValue(UserId, out var oldRecord))
|
||||
|
||||
Reference in New Issue
Block a user