Example #1
0
 public override int GetObjectEncodeSize(object value, bool arrayEncoding)
 {
     if (!arrayEncoding)
     {
         return(MapEncoding.GetEncodeSize((AmqpMap)value));
     }
     return(8 + MapEncoding.GetValueSize((AmqpMap)value));
 }
Example #2
0
 public static int GetEncodeSize(AmqpMap value)
 {
     if (value == null)
     {
         return(1);
     }
     return(1 + MapEncoding.GetEncodeWidth(value) * 2 + value.ValueSize);
 }
Example #3
0
 public override int GetObjectEncodeSize(object value, bool arrayEncoding)
 {
     if (arrayEncoding)
     {
         return(FixedWidth.UInt + FixedWidth.UInt + GetValueSize((AmqpMap)value));
     }
     else
     {
         return(MapEncoding.GetEncodeSize((AmqpMap)value));
     }
 }
Example #4
0
        public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer)
        {
            if (!arrayEncoding)
            {
                MapEncoding.Encode((AmqpMap)value, buffer);
                return;
            }
            AmqpMap amqpMaps  = (AmqpMap)value;
            int     valueSize = 4 + amqpMaps.ValueSize;

            MapEncoding.Encode(amqpMaps, 4, valueSize, buffer);
        }
Example #5
0
 public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer)
 {
     if (arrayEncoding)
     {
         AmqpMap mapValue = (AmqpMap)value;
         int     size     = FixedWidth.UInt + mapValue.ValueSize;
         MapEncoding.Encode(mapValue, FixedWidth.UInt, size, buffer);
     }
     else
     {
         MapEncoding.Encode((AmqpMap)value, buffer);
     }
 }
Example #6
0
        public static void Encode(AmqpMap value, ByteBuffer buffer)
        {
            if (value == null)
            {
                AmqpEncoding.EncodeNull(buffer);
                return;
            }
            int encodeWidth = MapEncoding.GetEncodeWidth(value);

            AmqpBitConverter.WriteUByte(buffer, (byte)((encodeWidth == 1 ? 193 : 209)));
            int valueSize = encodeWidth + value.ValueSize;

            MapEncoding.Encode(value, encodeWidth, valueSize, buffer);
        }
Example #7
0
        public static void Encode(AmqpMap value, ByteBuffer buffer)
        {
            if (value == null)
            {
                AmqpEncoding.EncodeNull(buffer);
            }
            else
            {
                int encodeWidth = MapEncoding.GetEncodeWidth(value);
                AmqpBitConverter.WriteUByte(buffer, encodeWidth == FixedWidth.UByte ? (byte)FormatCode.Map8 : (byte)FormatCode.Map32);

                int size = encodeWidth + value.ValueSize;
                MapEncoding.Encode(value, encodeWidth, size, buffer);
            }
        }
Example #8
0
        public static AmqpMap Decode(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return(null);
            }

            int size  = 0;
            int count = 0;

            AmqpEncoding.ReadSizeAndCount(buffer, formatCode, FormatCode.Map8, FormatCode.Map32, out size, out count);
            AmqpMap map = new AmqpMap();

            MapEncoding.ReadMapValue(buffer, map, size, count);
            return(map);
        }
Example #9
0
        public static AmqpMap Decode(ByteBuffer buffer, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode)
        {
            int num;
            int num1;

            if (formatCode == 0)
            {
                Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode1 = AmqpEncoding.ReadFormatCode(buffer);
                formatCode = formatCode1;
                if (formatCode1 == 64)
                {
                    return(null);
                }
            }
            AmqpEncoding.ReadSizeAndCount(buffer, formatCode, 193, 209, out num, out num1);
            AmqpMap amqpMaps = new AmqpMap();

            MapEncoding.ReadMapValue(buffer, amqpMaps, num, num1);
            return(amqpMaps);
        }
Example #10
0
 public override object DecodeObject(ByteBuffer buffer, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode)
 {
     return(MapEncoding.Decode(buffer, formatCode));
 }
Example #11
0
 public static int GetEncodeSize(AmqpMap value)
 {
     return(value == null ?
            FixedWidth.NullEncoded :
            FixedWidth.FormatCode + (MapEncoding.GetEncodeWidth(value) * 2) + value.ValueSize);
 }
Example #12
0
 public override object DecodeObject(ByteBuffer buffer, FormatCode formatCode)
 {
     return(MapEncoding.Decode(buffer, formatCode));
 }
Example #13
0
        static AmqpEncoding()
        {
            AmqpEncoding.booleanEncoding       = new BooleanEncoding();
            AmqpEncoding.ubyteEncoding         = new UByteEncoding();
            AmqpEncoding.ushortEncoding        = new UShortEncoding();
            AmqpEncoding.uintEncoding          = new UIntEncoding();
            AmqpEncoding.ulongEncoding         = new ULongEncoding();
            AmqpEncoding.byteEncoding          = new ByteEncoding();
            AmqpEncoding.shortEncoding         = new ShortEncoding();
            AmqpEncoding.intEncoding           = new IntEncoding();
            AmqpEncoding.longEncoding          = new LongEncoding();
            AmqpEncoding.floatEncoding         = new FloatEncoding();
            AmqpEncoding.doubleEncoding        = new DoubleEncoding();
            AmqpEncoding.decimal128Encoding    = new DecimalEncoding();
            AmqpEncoding.charEncoding          = new CharEncoding();
            AmqpEncoding.timeStampEncoding     = new TimeStampEncoding();
            AmqpEncoding.uuidEncoding          = new UuidEncoding();
            AmqpEncoding.binaryEncoding        = new BinaryEncoding();
            AmqpEncoding.symbolEncoding        = new SymbolEncoding();
            AmqpEncoding.stringEncoding        = new StringEncoding();
            AmqpEncoding.listEncoding          = new ListEncoding();
            AmqpEncoding.mapEncoding           = new MapEncoding();
            AmqpEncoding.arrayEncoding         = new ArrayEncoding();
            AmqpEncoding.describedTypeEncoding = new DescribedEncoding();
            Dictionary <Type, EncodingBase> types = new Dictionary <Type, EncodingBase>()
            {
                { typeof(bool), AmqpEncoding.booleanEncoding },
                { typeof(byte), AmqpEncoding.ubyteEncoding },
                { typeof(ushort), AmqpEncoding.ushortEncoding },
                { typeof(uint), AmqpEncoding.uintEncoding },
                { typeof(ulong), AmqpEncoding.ulongEncoding },
                { typeof(sbyte), AmqpEncoding.byteEncoding },
                { typeof(short), AmqpEncoding.shortEncoding },
                { typeof(int), AmqpEncoding.intEncoding },
                { typeof(long), AmqpEncoding.longEncoding },
                { typeof(float), AmqpEncoding.floatEncoding },
                { typeof(double), AmqpEncoding.doubleEncoding },
                { typeof(decimal), AmqpEncoding.decimal128Encoding },
                { typeof(char), AmqpEncoding.charEncoding },
                { typeof(DateTime), AmqpEncoding.timeStampEncoding },
                { typeof(Guid), AmqpEncoding.uuidEncoding },
                { typeof(ArraySegment <byte>), AmqpEncoding.binaryEncoding },
                { typeof(AmqpSymbol), AmqpEncoding.symbolEncoding },
                { typeof(string), AmqpEncoding.stringEncoding },
                { typeof(AmqpMap), AmqpEncoding.mapEncoding }
            };

            AmqpEncoding.encodingsByType = types;
            Dictionary <FormatCode, EncodingBase> formatCodes = new Dictionary <FormatCode, EncodingBase>()
            {
                { 66, AmqpEncoding.booleanEncoding },
                { 65, AmqpEncoding.booleanEncoding },
                { 86, AmqpEncoding.booleanEncoding },
                { 80, AmqpEncoding.ubyteEncoding },
                { 96, AmqpEncoding.ushortEncoding },
                { 112, AmqpEncoding.uintEncoding },
                { 82, AmqpEncoding.uintEncoding },
                { 67, AmqpEncoding.uintEncoding },
                { 128, AmqpEncoding.ulongEncoding },
                { 83, AmqpEncoding.ulongEncoding },
                { 68, AmqpEncoding.ulongEncoding },
                { 81, AmqpEncoding.byteEncoding },
                { 97, AmqpEncoding.shortEncoding },
                { 113, AmqpEncoding.intEncoding },
                { 84, AmqpEncoding.intEncoding },
                { 129, AmqpEncoding.longEncoding },
                { 85, AmqpEncoding.longEncoding },
                { 114, AmqpEncoding.floatEncoding },
                { 130, AmqpEncoding.doubleEncoding },
                { 148, AmqpEncoding.decimal128Encoding },
                { 115, AmqpEncoding.charEncoding },
                { 131, AmqpEncoding.timeStampEncoding },
                { 152, AmqpEncoding.uuidEncoding },
                { 160, AmqpEncoding.binaryEncoding },
                { 176, AmqpEncoding.binaryEncoding },
                { 163, AmqpEncoding.symbolEncoding },
                { 179, AmqpEncoding.symbolEncoding },
                { 161, AmqpEncoding.stringEncoding },
                { 177, AmqpEncoding.stringEncoding },
                { 69, AmqpEncoding.listEncoding },
                { 192, AmqpEncoding.listEncoding },
                { 208, AmqpEncoding.listEncoding },
                { 193, AmqpEncoding.mapEncoding },
                { 209, AmqpEncoding.mapEncoding },
                { 224, AmqpEncoding.arrayEncoding },
                { 240, AmqpEncoding.arrayEncoding },
                { 0, AmqpEncoding.describedTypeEncoding }
            };

            AmqpEncoding.encodingsByCode = formatCodes;
        }