const uint MORE_MASK = 0x80; // 1000 0000

        public static void WriteCompressedUInt(this IWriteBytes stream, uint value)
        {
            while (value > DATA_MASK)
            {
                stream.WriteByte((byte)((value & DATA_MASK)));
                value >>= 7;
            }
            stream.WriteByte((byte)(value | MORE_MASK));
        }
Exemplo n.º 2
0
 public static void WriteCompressedNullableBool(this IWriteBytes stream, bool?value)
 {
     if (null == value)
     {
         stream.WriteByte(2);
     }
     else
     {
         stream.WriteByte(value.Value ? (byte)1 : (byte)0);
     }
 }
Exemplo n.º 3
0
 public static void WriteCompressedBool(this IWriteBytes stream, bool value)
 {
     stream.WriteByte(value ? (byte)1 : (byte)0);
 }