Ejemplo n.º 1
0
 public override int GetObjectEncodeSize(object value, bool arrayEncoding)
 {
     if (!arrayEncoding)
     {
         return(StringEncoding.GetEncodeSize((string)value));
     }
     return(4 + System.Text.Encoding.UTF8.GetByteCount((string)value));
 }
Ejemplo n.º 2
0
 public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer)
 {
     if (!arrayEncoding)
     {
         StringEncoding.Encode((string)value, buffer);
         return;
     }
     StringEncoding.Encode(System.Text.Encoding.UTF8.GetBytes((string)value), 4, buffer);
 }
Ejemplo n.º 3
0
 public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer)
 {
     if (arrayEncoding)
     {
         StringEncoding.Encode((string)value, FixedWidth.UInt, buffer);
     }
     else
     {
         StringEncoding.Encode((string)value, buffer);
     }
 }
Ejemplo n.º 4
0
 public override int GetObjectEncodeSize(object value, bool arrayEncoding)
 {
     if (arrayEncoding)
     {
         return(FixedWidth.UInt + Encoding.UTF8.GetByteCount((string)value));
     }
     else
     {
         return(StringEncoding.GetEncodeSize((string)value));
     }
 }
Ejemplo n.º 5
0
 public static void Encode(string value, ByteBuffer buffer)
 {
     if (value == null)
     {
         AmqpEncoding.EncodeNull(buffer);
     }
     else
     {
         StringEncoding.Encode(value, 0, buffer);
     }
 }
Ejemplo n.º 6
0
        public static void Encode(string value, ByteBuffer buffer)
        {
            if (value == null)
            {
                AmqpEncoding.EncodeNull(buffer);
                return;
            }
            byte[] bytes             = System.Text.Encoding.UTF8.GetBytes(value);
            int    encodeWidthBySize = AmqpEncoding.GetEncodeWidthBySize((int)bytes.Length);

            AmqpBitConverter.WriteUByte(buffer, (byte)((encodeWidthBySize == 1 ? 161 : 177)));
            StringEncoding.Encode(bytes, encodeWidthBySize, buffer);
        }
Ejemplo n.º 7
0
 public override object DecodeObject(ByteBuffer buffer, FormatCode formatCode)
 {
     return(StringEncoding.Decode(buffer, formatCode));
 }
Ejemplo n.º 8
0
 public override object DecodeObject(ByteBuffer buffer, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode)
 {
     return(StringEncoding.Decode(buffer, formatCode));
 }
Ejemplo n.º 9
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;
        }