public object ReadPrimitive <T>() { if (typeof(T) == typeof(string)) { throw new UsCmdIOError(UsCmdIOErrorCode.TypeMismatched); } if (this._readOffset + Marshal.SizeOf(typeof(T)) > this._buffer.Length) { throw new UsCmdIOError(UsCmdIOErrorCode.ReadOverflow); } object obj = UsGeneric.Convert <T>(this._buffer, this._readOffset); this._readOffset += Marshal.SizeOf(typeof(T)); return(obj); }
public void WritePrimitive <T>(T value) { if (typeof(T) == typeof(string)) { throw new UsCmdIOError(UsCmdIOErrorCode.TypeMismatched); } if (this._writeOffset + Marshal.SizeOf(typeof(T)) > this._buffer.Length) { throw new UsCmdIOError(UsCmdIOErrorCode.WriteOverflow); } byte[] numArray = UsGeneric.Convert <T>(value); if (numArray == null) { throw new UsCmdIOError(UsCmdIOErrorCode.TypeMismatched); } numArray.CopyTo((Array)this._buffer, this._writeOffset); this._writeOffset += Marshal.SizeOf(typeof(T)); }