WIP db provider support for Mysql and Postgres

This commit is contained in:
Kwoth
2022-04-11 10:41:26 +00:00
parent 8e1ec2ed9e
commit e23233ee06
66 changed files with 21891 additions and 382 deletions

View File

@@ -190,13 +190,10 @@ public static class Extensions
return false;
}
public static long? GetImageSize(this HttpResponseMessage msg)
{
if (msg.Content.Headers.ContentLength is null)
return null;
return msg.Content.Headers.ContentLength.Value / 1.Mb();
}
public static long GetContentLength(this HttpResponseMessage msg)
=> msg.Content.Headers.ContentLength is long length
? length
: long.MaxValue;
public static string GetText(this IBotStrings strings, in LocStr str, ulong? guildId = null)
=> strings.GetText(str.Key, guildId, str.Params);

View File

@@ -2,45 +2,6 @@ namespace NadekoBot.Extensions;
public static class NumberExtensions
{
public static int KiB(this int value)
=> value * 1024;
public static int Kb(this int value)
=> value * 1000;
public static int MiB(this int value)
=> value.KiB() * 1024;
public static int Mb(this int value)
=> value.Kb() * 1000;
public static int GiB(this int value)
=> value.MiB() * 1024;
public static int Gb(this int value)
=> value.Mb() * 1000;
public static ulong KiB(this ulong value)
=> value * 1024;
public static ulong Kb(this ulong value)
=> value * 1000;
public static ulong MiB(this ulong value)
=> value.KiB() * 1024;
public static ulong Mb(this ulong value)
=> value.Kb() * 1000;
public static ulong GiB(this ulong value)
=> value.MiB() * 1024;
public static ulong Gb(this ulong value)
=> value.Mb() * 1000;
public static bool IsInteger(this decimal number)
=> number == Math.Truncate(number);
public static DateTimeOffset ToUnixTimestamp(this double number)
=> new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero).AddSeconds(number);
}