Пример #1
0
 static void VerifyBufferLength(ByteBuffer buffer, int length)
 {
     if (buffer.Length < length)
     {
         throw AmqpEncoding.GetEncodingException("length");
     }
 }
Пример #2
0
        public static string Decode(ByteBuffer buffer, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode)
        {
            int num;

            System.Text.Encoding uTF8;
            if (formatCode == 0)
            {
                Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode1 = AmqpEncoding.ReadFormatCode(buffer);
                formatCode = formatCode1;
                if (formatCode1 == 64)
                {
                    return(null);
                }
            }
            if (formatCode != 161)
            {
                if (formatCode != 177)
                {
                    throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidFormatCode(formatCode, buffer.Offset));
                }
                num  = (int)AmqpBitConverter.ReadUInt(buffer);
                uTF8 = System.Text.Encoding.UTF8;
            }
            else
            {
                num  = AmqpBitConverter.ReadUByte(buffer);
                uTF8 = System.Text.Encoding.UTF8;
            }
            string str = uTF8.GetString(buffer.Buffer, buffer.Offset, num);

            buffer.Complete(num);
            return(str);
        }
Пример #3
0
 public static void VerifyFormatCode(Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode expected, int offset)
 {
     if (formatCode != expected)
     {
         throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidFormatCode(formatCode, offset));
     }
 }
Пример #4
0
        private static DescribedType Decode(ByteBuffer buffer, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode)
        {
            if (formatCode != 0)
            {
                throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidFormatCode(formatCode, buffer.Offset));
            }
            object obj = AmqpEncoding.DecodeObject(buffer);

            return(new DescribedType(obj, AmqpEncoding.DecodeObject(buffer)));
        }
Пример #5
0
        public static object DecodeObject(ByteBuffer buffer, FormatCode formatCode)
        {
            EncodingBase encodingBase;

            if (!AmqpEncoding.encodingsByCode.TryGetValue(formatCode, out encodingBase))
            {
                throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidFormatCode(formatCode, buffer.Offset));
            }
            return(encodingBase.DecodeObject(buffer, formatCode));
        }
Пример #6
0
 public static void ReadCount(ByteBuffer buffer, FormatCode formatCode, FormatCode formatCode8, FormatCode formatCode32, out int count)
 {
     if (formatCode == formatCode8)
     {
         count = AmqpBitConverter.ReadUByte(buffer);
         return;
     }
     if (formatCode != formatCode32)
     {
         throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidFormatCode(formatCode, buffer.Offset));
     }
     count = (int)AmqpBitConverter.ReadUInt(buffer);
 }
Пример #7
0
        public static EncodingBase GetEncoding(Type type)
        {
            EncodingBase encodingBase = null;

            if (AmqpEncoding.encodingsByType.TryGetValue(type, out encodingBase))
            {
                return(encodingBase);
            }
            if (type.IsArray)
            {
                return(AmqpEncoding.arrayEncoding);
            }
            if (typeof(IList).IsAssignableFrom(type))
            {
                return(AmqpEncoding.listEncoding);
            }
            if (!typeof(DescribedType).IsAssignableFrom(type))
            {
                throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidType(type.ToString()));
            }
            return(AmqpEncoding.describedTypeEncoding);
        }
Пример #8
0
        private static decimal DecodeValue(ByteBuffer buffer, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode)
        {
            decimal num  = new decimal(0);
            byte    num1 = formatCode;

            if (num1 == 116)
            {
                num = DecimalEncoding.DecodeDecimal32(buffer);
            }
            else if (num1 == 132)
            {
                num = DecimalEncoding.DecodeDecimal64(buffer);
            }
            else
            {
                if (num1 != 148)
                {
                    throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidFormatCode(formatCode, buffer.Offset));
                }
                num = DecimalEncoding.DecodeDecimal128(buffer);
            }
            return(num);
        }
Пример #9
0
        public static EncodingBase GetEncoding(object value)
        {
            EncodingBase encodingBase = null;
            Type         type         = value.GetType();

            if (AmqpEncoding.encodingsByType.TryGetValue(type, out encodingBase))
            {
                return(encodingBase);
            }
            if (type.IsArray)
            {
                return(AmqpEncoding.arrayEncoding);
            }
            if (value is IList)
            {
                return(AmqpEncoding.listEncoding);
            }
            if (!(value is DescribedType))
            {
                throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidType(type.ToString()));
            }
            return(AmqpEncoding.describedTypeEncoding);
        }
Пример #10
0
        public static void VerifyFormatCode(Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode, int offset, params Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode[] expected)
        {
            bool flag = false;

            Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode[] formatCodeArray = expected;
            int num = 0;

            while (num < (int)formatCodeArray.Length)
            {
                if (formatCode != formatCodeArray[num])
                {
                    num++;
                }
                else
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidFormatCode(formatCode, offset));
            }
        }