Exemple #1
0
        public long ReadHeader(XmlReader reader, BrokeredMessage brokeredMessage, SerializationTarget serializationTarget)
        {
            byte[] numArray;
            long   num;
            List <ArraySegment <byte> > arraySegments = new List <ArraySegment <byte> >();
            long length = (long)0;

            if (serializationTarget == SerializationTarget.Communication)
            {
                reader.ReadStartElement();
            }
            do
            {
                numArray = AmqpMessageEncoder.ReadBytes(reader, 512);
                length   = length + (long)((int)numArray.Length);
                arraySegments.Add(new ArraySegment <byte>(numArray, 0, (int)numArray.Length));
            }while ((int)numArray.Length >= 512);
            if (serializationTarget == SerializationTarget.Communication)
            {
                reader.ReadEndElement();
            }
            using (BufferListStream bufferListStream = new BufferListStream(arraySegments.ToArray()))
            {
                using (AmqpMessage amqpMessage = AmqpMessage.CreateAmqpStreamMessageHeader(bufferListStream))
                {
                    amqpMessage.Deserialize(SectionFlag.NonBody);
                    brokeredMessage.MessageId = "nil";
                    AmqpMessageEncoder.UpdateBrokeredMessageHeaderAndProperties(amqpMessage, brokeredMessage, serializationTarget);
                    brokeredMessage.RawHeaderStream = amqpMessage.GetNonBodySectionsStream();
                    num = length;
                }
            }
            return(num);
        }
Exemple #2
0
        public long WriteHeader(XmlWriter writer, BrokeredMessage brokeredMessage, SerializationTarget serializationTarget)
        {
            long num;

            using (BufferListStream bufferListStream = BufferListStream.Create(brokeredMessage.RawHeaderStream, 512))
            {
                using (AmqpMessage amqpMessage = AmqpMessage.CreateAmqpStreamMessageHeader(bufferListStream))
                {
                    AmqpMessageEncoder.UpdateAmqpMessageHeadersAndProperties(brokeredMessage, amqpMessage, serializationTarget);
                    if (serializationTarget == SerializationTarget.Communication)
                    {
                        writer.WriteStartElement("MessageHeaders");
                    }
                    long num1 = amqpMessage.Write(writer);
                    if (serializationTarget == SerializationTarget.Communication)
                    {
                        writer.WriteEndElement();
                    }
                    num = num1;
                }
            }
            return(num);
        }