Inheritance: EncodingBase
コード例 #1
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));
     }
 }
コード例 #2
0
 public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer)
 {
     if (arrayEncoding)
     {
         StringEncoding.Encode(Encoding.UTF8.GetBytes((string)value), FixedWidth.UInt, buffer);
     }
     else
     {
         StringEncoding.Encode((string)value, buffer);
     }
 }
コード例 #3
0
 public static void Encode(string value, ByteBuffer buffer)
 {
     if (value == null)
     {
         AmqpEncoding.EncodeNull(buffer);
     }
     else
     {
         byte[] encodedData = Encoding.UTF8.GetBytes(value);
         int    encodeWidth = AmqpEncoding.GetEncodeWidthBySize(encodedData.Length);
         AmqpBitConverter.WriteUByte(buffer, encodeWidth == FixedWidth.UByte ? FormatCode.String8Utf8 : FormatCode.String32Utf8);
         StringEncoding.Encode(encodedData, encodeWidth, buffer);
     }
 }