/// <inheritdoc /> public bool TryReadUInt64(out ulong value) { if (CanAdvance(8)) { int start = UncheckedAdvance(8); value = LittleEndianBitConverter.ToUInt64(_buffer, start); return(true); } else { return(Misc.Fail(out value)); } }
/// <inheritdoc /> public bool TryReadInt32(out int value) { if (CanAdvance(4)) { int start = UncheckedAdvance(4); value = LittleEndianBitConverter.ToInt32(_buffer, start); return(true); } else { return(Misc.Fail(out value)); } }
private bool TryReadInt16(out short value, bool peek) { if (CanAdvance(2)) { int start = _currentOffset; if (!peek) { UncheckedAdvance(2); } value = LittleEndianBitConverter.ToInt16(_buffer, start); return(true); } else { return(Misc.Fail(out value)); } }
private short ReadInt16(bool peek) { int start; if (peek) { // If we just wanna peek, don't advance. if (!CanAdvance(2)) { throw PacketReadingException.EndOfStream(); } start = _currentOffset; } else { // Otherwise do advance. start = CheckedAdvance(2); } return(LittleEndianBitConverter.ToInt16(_buffer, start)); }
/// <inheritdoc /> /// <inheritdoc cref="CheckedAdvance" select="exception[@cref='PacketReadingException']" /> public ulong ReadUInt64() { int start = CheckedAdvance(8); return(LittleEndianBitConverter.ToUInt64(_buffer, start)); }
/// <inheritdoc /> /// <inheritdoc cref="CheckedAdvance" select="exception[@cref='PacketReadingException']" /> public uint ReadUInt32() { int start = CheckedAdvance(4); return(LittleEndianBitConverter.ToUInt32(_buffer, start)); }
/// <inheritdoc /> /// <inheritdoc cref="CheckedAdvance" select="exception[@cref='PacketReadingException']" /> public ushort ReadUInt16() { int start = CheckedAdvance(2); return(LittleEndianBitConverter.ToUInt16(_buffer, start)); }
/// <inheritdoc /> /// <inheritdoc cref="ThrowIfDisposed()" select="exception[@cref='ObjectDisposedException']" /> public void WriteInt16(ushort number) { ThrowIfDisposed(); WriteDirect(LittleEndianBitConverter.GetBytes(number)); }
/// <inheritdoc /> /// <inheritdoc cref="ThrowIfDisposed()" select="exception[@cref='ObjectDisposedException']" /> public void WriteBoolean(bool boolean) { ThrowIfDisposed(); WriteDirect(LittleEndianBitConverter.GetBytes(boolean)); }