public void AdvanceWhileWhitespace()
 {
     while (JsonTextMemoryReader.IsWhitespace(this.PeekCharacter()))
     {
         this.ReadCharacter();
     }
 }
            private void ProcessNumberValueToken()
            {
                ////https://tools.ietf.org/html/rfc7159#section-6
                ////number = [ minus ] int [ frac ] [ exp ]
                ////decimal-point = %x2E       ; .
                ////digit1-9 = %x31-39         ; 1-9
                ////e = %x65 / %x45            ; e E
                ////exp = e [ minus / plus ] 1*DIGIT
                ////frac = decimal-point 1*DIGIT
                ////int = zero / ( digit1-9 *DIGIT )
                ////minus = %x2D               ; -
                ////plus = %x2B                ; +
                ////zero = %x30                ;

                this.token.JsonTextTokenType = JsonTextTokenType.Number;

                // Check for optional sign.
                if (this.jsonTextBuffer.PeekCharacter() == '-')
                {
                    this.jsonTextBuffer.ReadCharacter();
                }

                // There MUST best at least one digit before the dot
                if (!char.IsDigit(this.jsonTextBuffer.PeekCharacter()))
                {
                    throw new JsonInvalidNumberException();
                }

                // Only zero or a float can have a zero
                if (this.jsonTextBuffer.PeekCharacter() == '0')
                {
                    this.jsonTextBuffer.ReadCharacter();
                    if (this.jsonTextBuffer.PeekCharacter() == '0')
                    {
                        throw new JsonInvalidNumberException();
                    }
                }
                else
                {
                    // Read all digits before the dot
                    while (char.IsDigit(this.jsonTextBuffer.PeekCharacter()))
                    {
                        this.jsonTextBuffer.ReadCharacter();
                    }
                }

                // Check for optional '.'
                if (this.jsonTextBuffer.PeekCharacter() == '.')
                {
                    this.token.JsonTextTokenType = JsonTextTokenType.Number;

                    this.jsonTextBuffer.ReadCharacter();

                    // There MUST best at least one digit after the dot
                    if (!char.IsDigit(this.jsonTextBuffer.PeekCharacter()))
                    {
                        throw new JsonInvalidNumberException();
                    }

                    // Read all digits after the dot
                    while (char.IsDigit(this.jsonTextBuffer.PeekCharacter()))
                    {
                        this.jsonTextBuffer.ReadCharacter();
                    }
                }

                // Check for optional e/E.
                if (this.jsonTextBuffer.PeekCharacter() == 'e' || this.jsonTextBuffer.PeekCharacter() == 'E')
                {
                    this.token.JsonTextTokenType = JsonTextTokenType.Number;
                    this.jsonTextBuffer.ReadCharacter();

                    // Check for optional +/- after e/E.
                    if (this.jsonTextBuffer.PeekCharacter() == '+' || this.jsonTextBuffer.PeekCharacter() == '-')
                    {
                        this.jsonTextBuffer.ReadCharacter();
                    }

                    // There MUST best at least one digit after the e/E and optional +/-
                    if (!char.IsDigit(this.jsonTextBuffer.PeekCharacter()))
                    {
                        throw new JsonInvalidNumberException();
                    }

                    // Read all digits after the e/E
                    while (char.IsDigit(this.jsonTextBuffer.PeekCharacter()))
                    {
                        this.jsonTextBuffer.ReadCharacter();
                    }
                }

                // Make sure no gargbage came after the number
                char current = this.jsonTextBuffer.PeekCharacter();

                if (!(this.jsonTextBuffer.IsEof || JsonTextMemoryReader.IsWhitespace(current) || current == '}' || current == ',' || current == ']'))
                {
                    throw new JsonInvalidNumberException();
                }
            }
 /// <summary>
 /// Initializes a new instance of the JsonTextReader class.
 /// </summary>
 /// <param name="buffer">The IJsonTextBuffer to read from.</param>
 public JsonTextReader(ReadOnlyMemory <byte> buffer)
 {
     this.jsonTextBuffer = new JsonTextMemoryReader(buffer);
 }
 /// <summary>
 /// Initializes a new instance of the JsonTextReader class.
 /// </summary>
 /// <param name="buffer">The IJsonTextBuffer to read from.</param>
 /// <param name="skipValidation">Whether or not to skip validation.</param>
 public JsonTextReader(ReadOnlyMemory <byte> buffer, bool skipValidation = false)
     : base(skipValidation)
 {
     this.jsonTextBuffer = new JsonTextMemoryReader(buffer);
 }