18 using Newtonsoft.Json;
21 using Newtonsoft.Json.Linq;
23 using System.Collections.Generic;
35 protected static readonly JsonSerializerSettings
Settings =
new() { TypeNameHandling = TypeNameHandling.All };
55 protected abstract IEnumerable<ICommand>
GetCommands();
72 List<CommandResultPacket> resultPackets =
null;
75 foreach (var command
in GetCommands().Where(c => c !=
null))
77 Log.
Trace($
"BaseCommandHandler.ProcessCommands(): {Messages.BaseCommandHandler.ExecutingCommand(command)}");
92 if(resultPackets ==
null)
94 resultPackets =
new List<CommandResultPacket>();
96 resultPackets.Add(result);
120 Dictionary<string, JToken> deserialized =
new(StringComparer.InvariantCultureIgnoreCase);
123 if (!
string.IsNullOrEmpty(payload))
125 var jobject = JObject.Parse(payload);
126 foreach (var kv
in jobject)
128 deserialized[kv.Key] = kv.Value;
132 catch (Exception err)
134 Log.
Error(err, $
"Payload: '{payload}'");
138 if (!deserialized.TryGetValue(
"id", out var
id) ||
id ==
null)
143 if (!deserialized.TryGetValue(
"$type", out var type) || type ==
null)