vars and target-typed new

This commit is contained in:
Kwoth
2021-12-20 00:15:39 +01:00
parent ee33313519
commit cd379fd308
75 changed files with 198 additions and 198 deletions

View File

@@ -94,9 +94,9 @@ public class CurrencyService : ICurrencyService, INService
public async Task AddBulkAsync(IEnumerable<ulong> userIds, IEnumerable<string> reasons, IEnumerable<long> amounts, bool gamble = false)
{
ulong[] idArray = userIds as ulong[] ?? userIds.ToArray();
string[] reasonArray = reasons as string[] ?? reasons.ToArray();
long[] amountArray = amounts as long[] ?? amounts.ToArray();
var idArray = userIds as ulong[] ?? userIds.ToArray();
var reasonArray = reasons as string[] ?? reasons.ToArray();
var amountArray = amounts as long[] ?? amounts.ToArray();
if (idArray.Length != reasonArray.Length || reasonArray.Length != amountArray.Length)
throw new ArgumentException("Cannot perform bulk operation. Arrays are not of equal length.");
@@ -104,7 +104,7 @@ public class CurrencyService : ICurrencyService, INService
var userIdHashSet = new HashSet<ulong>(idArray.Length);
using (var uow = _db.GetDbContext())
{
for (int i = 0; i < idArray.Length; i++)
for (var i = 0; i < idArray.Length; i++)
{
// i have to prevent same user changing more than once as it will cause db error
if (userIdHashSet.Add(idArray[i]))
@@ -126,7 +126,7 @@ public class CurrencyService : ICurrencyService, INService
var userIdHashSet = new HashSet<ulong>(idArray.Length);
using (var uow = _db.GetDbContext())
{
for (int i = 0; i < idArray.Length; i++)
for (var i = 0; i < idArray.Length; i++)
{
// i have to prevent same user changing more than once as it will cause db error
if (userIdHashSet.Add(idArray[i]))