示例#1
0
        internal void WriteMessage(MQMessage message)
        {
            Counter++;

            if (_settings.WriteMessageIndex)
            {
                _sw.WriteLine("* Index {0}", Counter);
            }

            if (_settings.WriteMessageDescriptor)
            {
                WriteMessageDescriptor(message.GetDescriptor());
            }

            WriteMessageContent(message);

            _sw.WriteLine();
        }
示例#2
0
        private bool ReadFileMessage(DumpReader reader, out MQMessage msg, bool simulate = false)
        {
            msg = null;

            if (!reader.ReadLine(false, false))
            {
                return(false);
            }

            if (reader.Line[0] != 'A' && reader.Line[0] != 'N')
            {
                throw new DumpException($"Expected message attribute at line {reader.LineNo}");
            }

            if (reader.Line[0] == 'N')
            {
                if (!reader.ReadLine(true, false))
                {
                    throw new DumpException("Invalid end of file. Expected message data");
                }
            }

            MQMessageDescriptor md = null;

            if (!simulate)
            {
                msg = new MQMessage();
                md  = msg.GetDescriptor();
            }

            while (reader.Line[0] == 'A')
            {
                LoadMessageAttribute(reader, md);

                if (!reader.ReadLine(true, false))
                {
                    throw new DumpException("Invalid end of file. Expected message data");
                }
            }

            if (reader.Line[0] != 'X' && reader.Line[0] != 'T' && reader.Line[0] != 'S')
            {
                throw new DumpException($"Expected message at line {reader.LineNo}");
            }

            while (reader.Line[0] == 'X' || reader.Line[0] == 'T' || reader.Line[0] == 'S')
            {
                int skip = 1;
                if (reader.Line[0] == 'T')
                {
                    skip += 1;
                }
                else
                {
                    while (skip < reader.Line.Length && reader.Line[skip] == ' ')
                    {
                        skip += 1;
                    }
                }

                if (skip < reader.Line.Length)
                {
                    switch (reader.Line[0])
                    {
                    case 'X':
                        ReadMessageHex(reader, skip, msg);
                        break;

                    case 'S':
                        ReadMessageLine(reader, skip, msg);
                        break;

                    case 'T':
                        ReadMessageTextLine(reader, skip, msg);
                        break;
                    }
                }

                if (!reader.ReadLine(true, false))
                {
                    break;
                }
            }

            return(true);
        }