using SCHALE.Common.NetworkProtocol; using Serilog; using System.Text.Json; namespace SCHALE.Common.Crypto { internal class ProtocolConverter { private Dictionary> ProtocolConversionMappings { get; set; } public ProtocolConverter() { var jsonPath = Path.Combine(Path.GetDirectoryName(AppContext.BaseDirectory), "protocol_converter_values.json"); if (!File.Exists(jsonPath)) { Log.Information("The Json file for Protocol Converter does not exist..."); return; } string protocolJson = File.ReadAllText(jsonPath); ProtocolConversionMappings = JsonSerializer.Deserialize>>(protocolJson); } public int TypeConversion(uint crc, Protocol protocol) { return ProtocolConversionMappings[(int)protocol][(int)crc]; } } }