private Data GetBinaryFromBody()

in src/NMS.AMQP/Provider/Amqp/Message/AmqpNmsBytesMessageFacade.cs [56:100]


        private Data GetBinaryFromBody()
        {
            RestrictedDescribed body = Message.BodySection;
            Data result = EMPTY_DATA;
            if (body == null)
            {
                return result;
            }
            else if (body is Data)
            {
                byte[] binary = (body as Data).Binary;
                if (binary != null && binary.Length != 0)
                {
                    return body as Data;
                }
            }
            else if (body is AmqpValue)
            {
                object value = (body as AmqpValue).Value;
                if (value == null)
                {
                    return result;
                }

                if (value is byte[])
                {
                    byte[] dataValue = value as byte[];
                    if (dataValue.Length > 0)
                    {
                        result = new Data();
                        result.Binary = dataValue;
                    }
                }
                else
                {
                    throw new IllegalStateException("Unexpected Amqp value content-type: " + value.GetType().FullName);
                }
            }
            else
            {
                throw new IllegalStateException("Unexpected body content-type: " + body.GetType().FullName);
            }

            return result;
        }