mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
Move some extension methods into their respective class files
This commit is contained in:
parent
7ab5e66d7b
commit
a0fc9d3826
7 changed files with 80 additions and 88 deletions
|
|
@ -197,4 +197,19 @@ namespace PluralKit.Core
|
|||
public override T[] Parse(object value) => Array.ConvertAll((TInner[]) value, v => _factory(v));
|
||||
}
|
||||
}
|
||||
|
||||
public static class DatabaseExt
|
||||
{
|
||||
public static async Task Execute(this IDatabase db, Func<IPKConnection, Task> func)
|
||||
{
|
||||
await using var conn = await db.Obtain();
|
||||
await func(conn);
|
||||
}
|
||||
|
||||
public static async Task<T> Execute<T>(this IDatabase db, Func<IPKConnection, Task<T>> func)
|
||||
{
|
||||
await using var conn = await db.Obtain();
|
||||
return await func(conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue