feat: add library scanning mechanic
This commit is contained in:
@@ -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<string, string> 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] + "}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user