public static double ReadFullDouble(this IReadBytes stream) { var bytes = new byte[8]; stream.ReadBytes(bytes, 0, 8); return(BitConverter.ToDouble(bytes, 0)); }
/// <summary> /// Reads <paramref name="count"/> bytes. /// </summary> /// <param name="count">The number of bytes to read.</param> /// <returns>The array of bytes that was read.</returns> /// <exception cref="EndOfStreamException">Thrown when the end of the stream is reached before the read is completed.</exception> public static byte[] ReadBytes(this IReadBytes reader, int count) { var bytes = new byte[count]; reader.ReadBytes(bytes, 0, count); return(bytes); }
public static byte[] ReadCompressedByteArray(this IReadBytes stream) { if (!stream.ReadCompressedBool()) { return(null); } var length = (int)stream.ReadCompressedUInt(); return(stream.ReadBytes(length)); }
public static string ReadCompressedString(this IReadBytes stream) { if (!stream.ReadCompressedBool()) { return(null); } var length = (int)UIntCompressor.ReadCompressedUInt(stream); var bytes = new byte[length]; stream.ReadBytes(bytes, 0, length); return(Encoding.GetString(bytes)); }