public static ulong Read7BitLongValue(this Stream s)
{
byte n = 0;
byte b = (byte) s.ReadByte();
ulong result = 0;
while ((b & 0x80) != 0 && n < 8)
{
result <<= 7;
result |= (ulong)(b & 0x7F);
b = (byte)s.ReadByte();
++n;
}
result <<= ((n < 8) ? 7 : 8); // Use all 8 bits from the 4th byte
result |= b;
return result;
}
public static void Write(this byte[] buffer,int offset, uint value)