/// <summary> /// Skips the subtree where the root is the current entry, and returns skipped byte length. /// </summary> /// <returns> /// Skipped byte length. /// If the subtree is not completed, then <c>null</c>. /// </returns> public long?Skip() { this.VerifyIsNotDisposed(); if (this._mode == UnpackerMode.Enumerating) { throw this.NewInvalidModeException(); } if (this._isSubtreeReading) { throw new InvalidOperationException("Unpacker is in 'Subtree' mode."); } this._mode = UnpackerMode.Skipping; var result = this.SkipCore(); if (result != null) { this.SetStable(); } return(result); }
public long?Skip() { this.VerifyIsNotDisposed(); switch (this._mode) { case UnpackerMode.Streaming: if (!this.Data.HasValue) { throw this.NewInvalidModeException(); } break; case UnpackerMode.Enumerating: throw this.NewInvalidModeException(); } this._mode = UnpackerMode.Skipping; if (this._isSubtreeReading) { throw new InvalidOperationException("Unpacker is in 'Subtree' mode."); } long?nullable = this.SkipCore(); if (nullable.HasValue) { this.SetStable(); } return(nullable); }
private void BeginSkip() { this.VerifyIsNotDisposed(); if (this._mode == UnpackerMode.Enumerating) { this.ThrowInvalidModeException(); } this._mode = UnpackerMode.Skipping; }
private void VerifyMode(UnpackerMode mode) { this.VerifyIsNotDisposed(); if (this._mode == UnpackerMode.Unknown) { this._mode = mode; } else if (this._mode != mode) { throw this.NewInvalidModeException(); } }
/// <summary> /// Verifies the mode. /// </summary> /// <param name="mode">The mode to be.</param> /// <exception cref="ObjectDisposedException"> /// Already disposed. /// </exception> /// <exception cref="InvalidOperationException"> /// Is in incompatible mode. /// </exception> private void VerifyMode(UnpackerMode mode) { this.VerifyIsNotDisposed(); if (this._mode == UnpackerMode.Unknown) { this._mode = mode; return; } if (this._mode != mode) { this.ThrowInvalidModeException(); } }
/// <summary> /// Skips the subtree where the root is the current entry, and returns skipped byte length. /// </summary> /// <returns> /// Skipped byte length. /// If the subtree is not completed, then <c>null</c>. /// </returns> public long?Skip() { this.VerifyIsNotDisposed(); switch (this._mode) { case UnpackerMode.Enumerating: { throw this.NewInvalidModeException(); } case UnpackerMode.Streaming: { if (!this.Data.HasValue) { throw this.NewInvalidModeException(); } // If the value exists, safe to transit skipping. break; } } this._mode = UnpackerMode.Skipping; if (this._isSubtreeReading) { throw new InvalidOperationException("Unpacker is in 'Subtree' mode."); } var result = this.SkipCore(); if (result != null) { this.SetStable(); } return(result); }
private void SetStable() { // Now, this instance can transit another mode. this._mode = UnpackerMode.Unknown; }
private void SetStable() { this._mode = UnpackerMode.Unknown; }