/// <summary> /// Disposes the enumerator. /// </summary> /// <param name="disposing">Indicates whether this was called during disposal /// (<see langword="true"/>) or finalization (<see langword="false"/>).</param> protected void Dispose(bool disposing) { if (disposing) { BytesEnumerator?.Dispose(); } }
/// <summary> /// Resets the state of the enumerator. /// </summary> /// <exception cref="ObjectDisposedException">The enumerator has been disposed.</exception> public virtual void Reset() { if (IsDisposed) { throw new ObjectDisposedException(null); } BytesEnumerator.Reset(); _current = default; CurrentByteOffset = 0; }
/// <summary> /// Ensures that there are bits left to be read from the byte enumerator, moving to the next /// byte if necessary/possible. If we move to another byte, <see cref="CurrentByteOffset"/> /// is changed accordingly. /// </summary> /// <returns>True if there are bits left, false if not.</returns> protected virtual bool EnsureBitsLeft() { while (CurrentByteOffset >= 8) { if (BytesEnumerator.MoveNext()) { CurrentByteOffset -= BitsInByte; } else { return(false); } } return(true); }