Beispiel #1
0
        static T[] Decode <T>(ByteBuffer buffer, int size, int count, FormatCode formatCode)
        {
            T[]          array      = new T[count];
            EncodingBase encoding   = AmqpEncoding.GetEncoding(formatCode);
            object       descriptor = null;

            if (formatCode == FormatCode.Described)
            {
                descriptor = AmqpEncoding.DecodeObject(buffer);
                formatCode = AmqpEncoding.ReadFormatCode(buffer);
            }

            for (int i = 0; i < count; ++i)
            {
                object value = encoding.DecodeObject(buffer, formatCode);
                if (descriptor != null)
                {
                    value = new DescribedType(descriptor, value);
                }

                array[i] = (T)value;
            }

            return(array);
        }
        private static T[] Decode <T>(ByteBuffer buffer, int size, int count, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode)
        {
            T[]          tArray   = new T[count];
            EncodingBase encoding = AmqpEncoding.GetEncoding(formatCode);
            object       obj      = null;

            if (formatCode == 0)
            {
                obj        = AmqpEncoding.DecodeObject(buffer);
                formatCode = AmqpEncoding.ReadFormatCode(buffer);
            }
            for (int i = 0; i < count; i++)
            {
                object describedType = encoding.DecodeObject(buffer, formatCode);
                if (obj != null)
                {
                    describedType = new DescribedType(obj, describedType);
                }
                tArray[i] = (T)describedType;
            }
            return(tArray);
        }