public unsafe T Read <T>() where T : struct { if (!this._canRead) { throw new NotSupportedException(); } sbyte *numPtr = this._buffer + this._position; T data = default(T); this._position = (sbyte *)(void *)Utilities.ReadAndPosition <T>((IntPtr)((void *)numPtr), ref data) - this._buffer; return(data); }
/// <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(); } sbyte *from = _buffer + _position; T result = default(T); _position = (sbyte *)Utilities.ReadAndPosition((IntPtr)from, ref result) - _buffer; return(result); } }