using Edge.Core.Parser.BinaryParser; using Edge.Core.Parser.BinaryParser.MessageEntity; using Edge.Core.Parser.BinaryParser.Util; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace Gilbarco_Pump { public class MessageTemplateLookup : IMessageTemplateLookup { /// /// Gets the default singleton instance of type MessageTemplateLookup. /// public static MessageTemplateLookup Default { get; } = new MessageTemplateLookup(); /// /// Create a message entity based on input whole message raw bytes which is: 2bytes Len + 1 byte AppId + 1 byte SSK /// + variable length message code + variable length message body /// /// whole message raw bytes /// new created message entity public Edge.Core.Parser.BinaryParser.MessageEntity.MessageTemplateBase GetMessageTemplateByRawBytes(byte[] bytes) { var commandCode = bytes.Skip(5).First(); throw new ArgumentException("Can't find correlated message entity type for incoming raw message bytes: " + bytes.Select(s => s.ToString("X").PadLeft(2, '0')).Aggregate((n, acc) => n + " " + acc)); } } }