예제 #1
0
 /// <summary>
 /// Reads 1 to 8 bits into a <see cref="byte"/>.
 /// </summary>
 /// <exception cref="EndOfMessageException"></exception>
 public static byte ReadByte(this IBitBuffer buffer, int bitCount)
 {
     if (!buffer.ReadByte(bitCount, out byte value))
     {
         throw new EndOfMessageException();
     }
     return(value);
 }
예제 #2
0
 /// <summary>
 /// Reads a 1-bit <see cref="bool"/>.
 /// </summary>
 public static bool ReadBit(this IBitBuffer buffer, out bool result)
 {
     if (!buffer.ReadByte(1, out byte value))
     {
         result = default;
         return(false);
     }
     result = value > 0;
     return(true);
 }