mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
vars and target-typed new
This commit is contained in:
@@ -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]))
|
||||
|
@@ -23,7 +23,7 @@ public class FontProvider : INService
|
||||
{
|
||||
try
|
||||
{
|
||||
string fontsfolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts);
|
||||
var fontsfolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts);
|
||||
FallBackFonts.Add(_fonts.Install(Path.Combine(fontsfolder, "seguiemj.ttf")));
|
||||
FallBackFonts.AddRange(_fonts.InstallCollection(Path.Combine(fontsfolder, "msgothic.ttc")));
|
||||
FallBackFonts.AddRange(_fonts.InstallCollection(Path.Combine(fontsfolder, "segoe.ttc")));
|
||||
|
@@ -151,7 +151,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
|
||||
string nextPageToken = null;
|
||||
|
||||
List<string> toReturn = new List<string>(count);
|
||||
var toReturn = new List<string>(count);
|
||||
|
||||
do
|
||||
{
|
||||
@@ -178,7 +178,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
await Task.Yield();
|
||||
var videoIdsList = videoIds as List<string> ?? videoIds.ToList();
|
||||
|
||||
Dictionary<string, TimeSpan> toReturn = new Dictionary<string, TimeSpan>();
|
||||
var toReturn = new Dictionary<string, TimeSpan>();
|
||||
|
||||
if (!videoIdsList.Any())
|
||||
return toReturn;
|
||||
|
@@ -174,7 +174,7 @@ public class RedisCache : IDataCache
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
|
||||
RedisValue data = await _db.StringGetAsync(key).ConfigureAwait(false);
|
||||
var data = await _db.StringGetAsync(key).ConfigureAwait(false);
|
||||
if (!data.HasValue)
|
||||
{
|
||||
var obj = await factory(param).ConfigureAwait(false);
|
||||
|
@@ -21,7 +21,7 @@ public sealed class RedisImagesCache : IImageCache, IReadyExecutor
|
||||
private IDatabase _db => _con.GetDatabase();
|
||||
|
||||
private const string _basePath = "data/";
|
||||
private const string _cardsPath = "data/images/cards";
|
||||
private const string _cardsPath = $"{_basePath}images/cards";
|
||||
|
||||
public ImageUrls ImageUrls { get; private set; }
|
||||
|
||||
|
@@ -18,7 +18,7 @@ public class SoundCloudApiService : INService
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
throw new ArgumentNullException(nameof(url));
|
||||
|
||||
string response = "";
|
||||
var response = string.Empty;
|
||||
|
||||
using (var http = _httpFactory.CreateClient())
|
||||
{
|
||||
@@ -37,7 +37,7 @@ public class SoundCloudApiService : INService
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
|
||||
var response = "";
|
||||
var response = string.Empty;
|
||||
using (var http = _httpFactory.CreateClient())
|
||||
{
|
||||
response = await http.GetStringAsync(new Uri($"https://scapi.nadeko.bot/tracks?q={Uri.EscapeDataString(query)}")).ConfigureAwait(false);
|
||||
@@ -55,17 +55,17 @@ public class SoundCloudApiService : INService
|
||||
|
||||
public class SoundCloudVideo
|
||||
{
|
||||
public string Kind { get; set; } = "";
|
||||
public string Kind { get; set; } = string.Empty;
|
||||
public long Id { get; set; } = 0;
|
||||
public SoundCloudUser User { get; set; } = new SoundCloudUser();
|
||||
public string Title { get; set; } = "";
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string FullName => User.Name + " - " + Title;
|
||||
public bool? Streamable { get; set; } = false;
|
||||
public int Duration { get; set; }
|
||||
[JsonProperty("permalink_url")]
|
||||
public string TrackLink { get; set; } = "";
|
||||
public string TrackLink { get; set; } = string.Empty;
|
||||
[JsonProperty("artwork_url")]
|
||||
public string ArtworkUrl { get; set; } = "";
|
||||
public string ArtworkUrl { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class SoundCloudUser
|
||||
|
Reference in New Issue
Block a user