Ejemplo n.º 1
0
 /// <summary>
 /// Reads bytes into the given span.
 /// </summary>
 /// <param name="destination">The destination span.</param>
 public static int StreamRead(this IBitBuffer buffer, Span <byte> destination)
 {
     if (buffer.IsByteAligned())
     {
         int remainingBytes = Math.Min(buffer.ByteLength - buffer.BytePosition, destination.Length);
         buffer.Read(destination.Slice(0, remainingBytes));
         return(remainingBytes);
     }
     else
     {
         int remainingBits = Math.Min(buffer.BitLength - buffer.BitPosition, destination.Length * 8);
         buffer.ReadBits(destination, remainingBits);
         return(NetUtility.DivBy8(remainingBits));
     }
 }