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); }
public static string Decode(ByteBuffer buffer, FormatCode formatCode) { if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null) { return(null); } int count = 0; Encoding encoding = null; if (formatCode == FormatCode.String8Utf8) { count = (int)AmqpBitConverter.ReadUByte(buffer); encoding = Encoding.UTF8; } else if (formatCode == FormatCode.String32Utf8) { count = (int)AmqpBitConverter.ReadUInt(buffer); encoding = Encoding.UTF8; } else { throw AmqpEncoding.GetInvalidFormatCodeException(formatCode, buffer.Offset); } ArraySegment <byte> bytes = buffer.GetBytes(count); return(encoding.GetString(bytes.Array, bytes.Offset, count)); }
private static decimal DecodeDecimal64(ByteBuffer buffer) { byte[] numArray = new byte[8]; AmqpBitConverter.ReadBytes(buffer, numArray, 0, (int)numArray.Length); int num = 1; int num1 = 0; num = ((numArray[0] & 128) != 0 ? -1 : 1); if ((numArray[0] & 96) != 96) { num1 = (numArray[0] & 127) << 3 | (numArray[1] & 224) >> 5; numArray[0] = 0; numArray[1] = (byte)(numArray[1] & 31); } else if ((numArray[0] & 120) == 0) { num1 = (numArray[0] & 31) << 8 | (numArray[1] & 248) >> 3; numArray[0] = 0; numArray[1] = (byte)(numArray[1] & 7); numArray[1] = (byte)(numArray[1] | 32); } int num2 = (int)AmqpBitConverter.ReadUInt(numArray, 0, 4); int num3 = (int)AmqpBitConverter.ReadUInt(numArray, 4, 4); return(DecimalEncoding.CreateDecimal(num3, num2, 0, num, num1 - 398)); }
public static uint PeekUInt(ByteBuffer buffer) { buffer.Validate(false, 4); uint num = AmqpBitConverter.ReadUInt(buffer.Buffer, buffer.Offset, buffer.Length); return(num); }
unsafe static decimal DecodeDecimal128(ByteBuffer buffer) { byte[] bytes = new byte[FixedWidth.Decimal128]; buffer.ReadBytes(bytes, 0, bytes.Length); int sign = 1; int exponent = 0; sign = (bytes[0] & 0x80) != 0 ? -1 : 1; if ((bytes[0] & 0x60) != 0x60) { // s 14-bit-exponent (0)113-bit-significant exponent = ((bytes[0] & 0x7F) << 7) | ((bytes[1] & 0xFE) >> 1); bytes[0] = 0; bytes[1] &= 0x1; } else if ((bytes[0] & 0x78) != 0) { // handle NaN and Infinity } else { // s 11 14-bit-exponent (100)111-bit-significant // it is out of the valid range already. Should not be used return(0); } int high = (int)AmqpBitConverter.ReadUInt(bytes, 4, 4); int middle = (int)AmqpBitConverter.ReadUInt(bytes, 8, 4); int low = (int)AmqpBitConverter.ReadUInt(bytes, 12, 4); return(CreateDecimal(low, middle, high, sign, exponent - Decimal128Bias)); }
static decimal DecodeDecimal64(ByteBuffer buffer) { byte[] bytes = new byte[FixedWidth.Decimal64]; buffer.ReadBytes(bytes, 0, bytes.Length); int sign = 1; int exponent = 0; sign = (bytes[0] & 0x80) != 0 ? -1 : 1; if ((bytes[0] & 0x60) != 0x60) { // s 10-bit-exponent (0)53-bit-significant exponent = ((bytes[0] & 0x7F) << 3) | ((bytes[1] & 0xE0) >> 5); bytes[0] = 0; bytes[1] &= 0x1F; } else if ((bytes[0] & 0x78) != 0) { // handle NaN and Infinity } else { // s 11 10-bit-exponent (100)51-bit-significant exponent = ((bytes[0] & 0x1F) << 8) | ((bytes[1] & 0xF8) >> 3); bytes[0] = 0; bytes[1] &= 0x7; bytes[1] |= 0x20; } int middle = (int)AmqpBitConverter.ReadUInt(bytes, 0, 4); int low = (int)AmqpBitConverter.ReadUInt(bytes, 4, 4); return(CreateDecimal(low, middle, 0, sign, exponent - Decimal64Bias)); }
unsafe static decimal DecodeDecimal32(ByteBuffer buffer) { byte[] bytes = new byte[FixedWidth.Decimal32]; buffer.ReadBytes(bytes, 0, bytes.Length); int sign = 1; int exponent = 0; sign = (bytes[0] & 0x80) != 0 ? -1 : 1; if ((bytes[0] & 0x60) != 0x60) { // s 8-bit-exponent (0)23-bit-significant exponent = ((bytes[0] & 0x7F) << 1) | ((bytes[1] & 0x80) >> 7); bytes[0] = 0; bytes[1] &= 0x7F; } else if ((bytes[0] & 0x78) != 0) { // handle NaN and Infinity } else { // s 11 8-bit-exponent (100)21-bit-significant exponent = ((bytes[0] & 0x1F) << 3) | ((bytes[1] & 0xE0) >> 5); bytes[0] = 0; bytes[1] &= 0x1F; bytes[1] |= 0x80; } int low = (int)AmqpBitConverter.ReadUInt(bytes, 0, bytes.Length); return(CreateDecimal(low, 0, 0, sign, exponent - Decimal32Bias)); }
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); }
public static void ReadCount(ByteBuffer buffer, FormatCode formatCode, FormatCode formatCode8, FormatCode formatCode32, out int count) { if (formatCode == formatCode8) { count = AmqpBitConverter.ReadUByte(buffer); } else if (formatCode == formatCode32) { count = (int)AmqpBitConverter.ReadUInt(buffer); } else { throw GetInvalidFormatCodeException(formatCode, buffer.Offset); } }
private static decimal DecodeDecimal128(ByteBuffer buffer) { byte[] numArray = new byte[16]; AmqpBitConverter.ReadBytes(buffer, numArray, 0, (int)numArray.Length); int num = 1; int num1 = 0; num = ((numArray[0] & 128) != 0 ? -1 : 1); if ((numArray[0] & 96) != 96) { num1 = (numArray[0] & 127) << 7 | (numArray[1] & 254) >> 1; numArray[0] = 0; numArray[1] = (byte)(numArray[1] & 1); } else if ((numArray[0] & 120) == 0) { return(new decimal(0)); } int num2 = (int)AmqpBitConverter.ReadUInt(numArray, 4, 4); int num3 = (int)AmqpBitConverter.ReadUInt(numArray, 8, 4); int num4 = (int)AmqpBitConverter.ReadUInt(numArray, 12, 4); return(DecimalEncoding.CreateDecimal(num4, num3, num2, num, num1 - 6176)); }
public static uint?Decode(ByteBuffer buffer, Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode) { if (formatCode == 0) { Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode formatCode1 = AmqpEncoding.ReadFormatCode(buffer); formatCode = formatCode1; if (formatCode1 == 64) { return(null); } } int offset = buffer.Offset; Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode[] formatCodeArray = new Microsoft.ServiceBus.Messaging.Amqp.Encoding.FormatCode[] { 112, 82, 67 }; EncodingBase.VerifyFormatCode(formatCode, offset, formatCodeArray); if (formatCode == 67) { return(new uint?(0)); } return(new uint?((formatCode == 82 ? (uint)AmqpBitConverter.ReadUByte(buffer) : AmqpBitConverter.ReadUInt(buffer)))); }