コード例 #1
0
ファイル: Unpacker.cs プロジェクト: Coflys/msgpack-cli
        /// <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);
        }
コード例 #2
0
ファイル: Unpacker.cs プロジェクト: TonyDongGuaPi/joework
        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);
        }
コード例 #3
0
        private void BeginSkip()
        {
            this.VerifyIsNotDisposed();

            if (this._mode == UnpackerMode.Enumerating)
            {
                this.ThrowInvalidModeException();
            }

            this._mode = UnpackerMode.Skipping;
        }
コード例 #4
0
ファイル: Unpacker.cs プロジェクト: TonyDongGuaPi/joework
 private void VerifyMode(UnpackerMode mode)
 {
     this.VerifyIsNotDisposed();
     if (this._mode == UnpackerMode.Unknown)
     {
         this._mode = mode;
     }
     else if (this._mode != mode)
     {
         throw this.NewInvalidModeException();
     }
 }
コード例 #5
0
        /// <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();
            }
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
 private void SetStable()
 {
     // Now, this instance can transit another mode.
     this._mode = UnpackerMode.Unknown;
 }
コード例 #8
0
ファイル: Unpacker.cs プロジェクト: TonyDongGuaPi/joework
 private void SetStable()
 {
     this._mode = UnpackerMode.Unknown;
 }