feat: add library scanning mechanic

This commit is contained in:
2026-01-26 04:35:12 +01:00
parent 3a68531fb4
commit d46a2573c4
7 changed files with 355 additions and 14 deletions

View File

@@ -5,10 +5,10 @@ using System.Text;
namespace Shadow.Tools;
public class GeneralUseHelpers(ApplicationDbContext db, IConfiguration appsettings)
public class GeneralUseHelpers(ApplicationDbContext? db = null, IConfiguration? appsettings = null)
{
private readonly ApplicationDbContext _db = db;
private readonly IConfiguration _appsettings = appsettings;
private readonly ApplicationDbContext? _db = db;
private readonly IConfiguration? _appsettings = appsettings;
//async public Task<User?> GetUserFromEmail(string email)
@@ -27,4 +27,23 @@ public class GeneralUseHelpers(ApplicationDbContext db, IConfiguration appsettin
// }
//}
/// <summary>
/// Quick and dirty Dictionary&lt;string, string&gt; to JSON serializer
/// </summary>
/// <param name="dict">Dictionary with keypair of two strings</param>
/// <returns>Minified JSON</returns>
public static string DictAsJson(Dictionary<string, string> dict)
{
string resultJson = String.Empty;
foreach (string key in dict.Keys)
{
string cleanKey = key.Replace("\"", "\\\""); // "a"b" -> "a\"b"
string cleanValue = dict[key].Replace("\"", "\\\"");
resultJson += $"\"{cleanKey}\": \"{cleanValue}\", " // "key": "val",<space>
.Replace(@"\", @"\\"); // a\b -> a\\b
}
return "{" + resultJson[..^2] + "}";
}
}