public static Message Decode()

in src/Message.cs [177:240]


        public static Message Decode(ByteBuffer buffer)
        {
            Message message = new Message();

            DataList dataList = null;
            while (buffer.Length > 0)
            {
                var described = (RestrictedDescribed)Codec.Decode(buffer);
                if (described.Descriptor.Code == Codec.Header.Code)
                {
                    message.Header = (Header)described;
                }
                else if (described.Descriptor.Code == Codec.DeliveryAnnotations.Code)
                {
                    message.DeliveryAnnotations = (DeliveryAnnotations)described;
                }
                else if (described.Descriptor.Code == Codec.MessageAnnotations.Code)
                {
                    message.MessageAnnotations = (MessageAnnotations)described;
                }
                else if (described.Descriptor.Code == Codec.Properties.Code)
                {
                    message.Properties = (Properties)described;
                }
                else if (described.Descriptor.Code == Codec.ApplicationProperties.Code)
                {
                    message.ApplicationProperties = (ApplicationProperties)described;
                }
                else if (described.Descriptor.Code == Codec.Data.Code)
                {
                    if (message.BodySection == null)
                    {
                        message.BodySection = described;
                    }
                    else
                    {
                        if (dataList == null)
                        {
                            dataList = new DataList();
                            dataList.Add((Data)message.BodySection);
                            message.BodySection = dataList;
                        }

                        dataList.Add((Data)described);
                    }
                }
                else if (described.Descriptor.Code == Codec.AmqpValue.Code ||
                    described.Descriptor.Code == Codec.AmqpSequence.Code)
                {
                    message.BodySection = described;
                }
                else if (described.Descriptor.Code == Codec.Footer.Code)
                {
                    message.Footer = (Footer)described;
                }
                else
                {
                    throw new AmqpException(ErrorCode.FramingError,
                        Fx.Format(SRAmqp.AmqpUnknownDescriptor, described.Descriptor));
                }
            }

            return message;
        }