/// <summary> /// Reads a single value from the current stream and advances the current /// position within this stream by the number of bytes read. /// </summary> /// <remarks> /// In order to provide faster read/write, this operation doesn't check stream bound. /// A client must carefully not read/write above the size of this datastream. /// </remarks> /// <typeparam name = "T">The type of the value to be read from the stream.</typeparam> /// <returns>The value that was read.</returns> /// <exception cref = "T:System.NotSupportedException">This stream does not support reading.</exception> public T Read <T>() where T : struct { unsafe { if (!_canRead) { throw new NotSupportedException(); } byte *from = _buffer + _position; T result = default(T); _position = (byte *)SdxUtilities.ReadAndPosition((IntPtr)from, ref result) - _buffer; return(result); } }