From 9bb9ca63a7601cfaa75bfbc104c75249477dc05d Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Fri, 2 Jan 2026 18:56:22 -0600 Subject: [PATCH] Removed Newtonsoft --- .../Commands/Kasino/BlackjackCommand.cs | 12 ++++----- KfChatDotNetBot/Extensions/Extensions.cs | 27 ------------------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs b/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs index 670694a..c274603 100644 --- a/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs @@ -1,4 +1,5 @@ -using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.RegularExpressions; using KfChatDotNetBot.Extensions; using KfChatDotNetBot.Models; using KfChatDotNetBot.Models.DbModels; @@ -6,7 +7,6 @@ using KfChatDotNetBot.Services; using KfChatDotNetBot.Settings; using KfChatDotNetWsClient.Models.Events; using Microsoft.EntityFrameworkCore; -using NLog; using RandN.Compat; using RandN; @@ -106,7 +106,7 @@ public class BlackjackCommand : ICommand } else { - var existingGameState = existingGame.GameMeta.JsonDeserialize(); + var existingGameState = JsonSerializer.Deserialize(existingGame.GameMeta); if (existingGameState == null) { @@ -177,7 +177,7 @@ public class BlackjackCommand : ICommand newGameState.WagerId = createdWager.Id; db.Attach(createdWager); - createdWager.GameMeta = newGameState.JsonSerialize(); + createdWager.GameMeta = JsonSerializer.Serialize(newGameState); await db.SaveChangesAsync(ctx); // Check for immediate blackjacks @@ -240,7 +240,7 @@ public class BlackjackCommand : ICommand return; } - var currentGameState = activeWager.GameMeta.JsonDeserialize(); + var currentGameState = JsonSerializer.Deserialize(activeWager.GameMeta); if (currentGameState == null) { @@ -321,7 +321,7 @@ public class BlackjackCommand : ICommand // Continue game await using var db = new ApplicationDbContext(); db.Attach(wager); - wager.GameMeta = gameState.JsonSerialize(); + wager.GameMeta = JsonSerializer.Serialize(gameState); await db.SaveChangesAsync(ctx); await botInstance.SendChatMessageAsync( diff --git a/KfChatDotNetBot/Extensions/Extensions.cs b/KfChatDotNetBot/Extensions/Extensions.cs index f6c6759..f9eca18 100644 --- a/KfChatDotNetBot/Extensions/Extensions.cs +++ b/KfChatDotNetBot/Extensions/Extensions.cs @@ -1,7 +1,6 @@ using System.Text; using System.Text.RegularExpressions; using KfChatDotNetBot.Models.DbModels; -using Newtonsoft.Json; namespace KfChatDotNetBot.Extensions; @@ -138,30 +137,4 @@ public static class Extensions { return $"@{user.KfUsername}"; } - - /// - /// Deserialize a JSON string to the specified type using Newtonsoft.Json - /// - /// Type to deserialize to - /// JSON string to deserialize - /// Deserialized object or null if string is null/empty - public static T? JsonDeserialize(this string? jsonString) where T : class - { - if (string.IsNullOrEmpty(jsonString)) - { - return null; - } - - return JsonConvert.DeserializeObject(jsonString); - } - - /// - /// Serialize an object to JSON string using Newtonsoft.Json - /// - /// Object to serialize - /// JSON string representation - public static string JsonSerialize(this object obj) - { - return JsonConvert.SerializeObject(obj, Formatting.Indented); - } } \ No newline at end of file