public String DecodeSBEMessageQATEngine(byte[] MessageBytes)
        {
            StringBuilder sb           = new StringBuilder();
            var           directBuffer = new DirectBuffer(MessageBytes);
            int           bufferOffset = 0;

            ushort blockLength = directBuffer.Uint16GetLittleEndian(bufferOffset);

            bufferOffset += 2;
            sb.AppendLine(CrackHelper.CreateLine("Header", "BlockLength", blockLength.ToString()));

            ushort templateId = directBuffer.Uint16GetLittleEndian(bufferOffset);

            bufferOffset += 2;
            sb.AppendLine(CrackHelper.CreateLine("Header", "TemplateId", templateId.ToString()));

            ushort schemaId = directBuffer.Uint16GetLittleEndian(bufferOffset);

            bufferOffset += 2;
            sb.AppendLine(CrackHelper.CreateLine("Header", "SchemaId", schemaId.ToString()));

            ushort version = directBuffer.Uint16GetLittleEndian(bufferOffset);

            bufferOffset += 2;
            sb.AppendLine(CrackHelper.CreateLine("Header", "Version", version.ToString()));

            SbeMessage Message = SbeLoader.LoadMessageById(templateId.ToString());

            if (Message == null)
            {
                throw new Exception("Message not recognized! TemplateId = " + templateId.ToString());
            }

            foreach (SbeField field in Message.Fields)
            {
                FillValue(directBuffer, field, ref bufferOffset);
            }

            sb.Append(Message.Crack());
            return(sb.ToString());
        }
        public String DecodeSBEMessage(byte[] MessageBytes)
        {
            if (_Assembly == null)
            {
                throw new Exception("To use SBE Engine, please init SbeReflectionWrapper passing the sbe file dll as parameter");
            }

            StringBuilder sb            = new StringBuilder();
            var           directBuffer  = new DirectBuffer(MessageBytes);
            int           bufferOffset  = 0;
            const short   SchemaVersion = 0;

            Type MessageHeaderType = ReflectionHelper.GetType(_Assembly, _Header);
            var  MessageHeaderObj  = ReflectionHelper.GetObjectByType(_Assembly, _Header);

            //WRAP
            MessageHeaderType.InvokeMember("Wrap", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public,
                                           null, MessageHeaderObj, new object[] { directBuffer, bufferOffset, SchemaVersion });

            PropertyInfo pi         = ReflectionHelper.GetPropertyByName(_Assembly, _Header, "TemplateId");
            string       templateId = pi.GetValue(MessageHeaderObj).ToString().Trim();

            Type MessageBodyType = ReflectionHelper.GetMessageTypeByTemplateId(_Assembly, templateId);

            if (MessageBodyType == null)
            {
                throw new Exception(String.Format("TemplateID = {0} not found in the binary!", templateId));
            }

            SbeMessage Message = SbeLoader.LoadMessageById(templateId);

            if (Message == null)
            {
                throw new Exception(String.Format("TemplateID = {0} not found in the protocol!", templateId));
            }

            PropertyInfo blockLength = ReflectionHelper.GetPropertyByName(_Assembly, _Header, "blockLength");
            PropertyInfo schemaId    = ReflectionHelper.GetPropertyByName(_Assembly, _Header, "schemaId");
            PropertyInfo version     = ReflectionHelper.GetPropertyByName(_Assembly, _Header, "version");

            sb.AppendLine(CrackHelper.CreateLine("Header", "BlockLength", blockLength.GetValue(MessageHeaderObj).ToString().Trim()));
            sb.AppendLine(CrackHelper.CreateLine("Header", "TemplateID", String.Format("{0} ({1})", templateId, Message.Name)));
            sb.AppendLine(CrackHelper.CreateLine("Header", "SchemaId", schemaId.GetValue(MessageHeaderObj).ToString().Trim()));
            sb.AppendLine(CrackHelper.CreateLine("Header", "Version", version.GetValue(MessageHeaderObj).ToString().Trim()));

            var       MessageBodyObj = ReflectionHelper.GetObjectByType(_Assembly, MessageBodyType.FullName);
            FieldInfo size           = ReflectionHelper.GetFieldByName(_Assembly, _Header, "Size");

            bufferOffset += int.Parse(size.GetValue(MessageHeaderObj).ToString());

            FieldInfo actingBlockLength = ReflectionHelper.GetFieldByName(_Assembly, MessageBodyType.Name, "BlockLength");
            FieldInfo actingVersion     = ReflectionHelper.GetFieldByName(_Assembly, MessageBodyType.Name, "Version");

            MessageBodyType.InvokeMember("WrapForDecode", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public,
                                         null, MessageBodyObj, new object[] {
                directBuffer,
                bufferOffset,
                int.Parse(actingBlockLength.GetValue(MessageHeaderObj).ToString()),
                int.Parse(actingVersion.GetValue(MessageHeaderObj).ToString())
            });

            Message.FillFields(_Assembly, MessageBodyObj);
            sb.Append(Message.Crack());
            return(sb.ToString());
        }