Blackjack (#18)

* Blackjack

* idk
This commit is contained in:
CrackmaticSoftware
2026-01-03 00:12:46 +01:00
committed by GitHub
parent 77dad18e92
commit df869c6e82
4 changed files with 712 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
using System.Text;
using System.Text.RegularExpressions;
using KfChatDotNetBot.Models.DbModels;
using Newtonsoft.Json;
namespace KfChatDotNetBot.Extensions;
@@ -137,4 +138,30 @@ public static class Extensions
{
return $"@{user.KfUsername}";
}
/// <summary>
/// Deserialize a JSON string to the specified type using Newtonsoft.Json
/// </summary>
/// <typeparam name="T">Type to deserialize to</typeparam>
/// <param name="jsonString">JSON string to deserialize</param>
/// <returns>Deserialized object or null if string is null/empty</returns>
public static T? JsonDeserialize<T>(this string? jsonString) where T : class
{
if (string.IsNullOrEmpty(jsonString))
{
return null;
}
return JsonConvert.DeserializeObject<T>(jsonString);
}
/// <summary>
/// Serialize an object to JSON string using Newtonsoft.Json
/// </summary>
/// <param name="obj">Object to serialize</param>
/// <returns>JSON string representation</returns>
public static string JsonSerialize(this object obj)
{
return JsonConvert.SerializeObject(obj, Formatting.Indented);
}
}