DynamicRest.JsonReader.ReadString C# (CSharp) Method

ReadString() private method

private ReadString ( bool &hasLeadingSlash ) : string
hasLeadingSlash bool
return string
        private string ReadString(out bool hasLeadingSlash)
        {
            StringBuilder sb = new StringBuilder();

            char endQuoteCharacter = (char)_reader.Read();
            bool inEscape = false;
            bool firstCharacter = true;

            hasLeadingSlash = false;

            while (true) {
                char ch = GetNextCharacter();
                if (ch == '\0') {
                    throw new FormatException("Unterminated string literal.");
                }
                if (firstCharacter) {
                    if (ch == '\\') {
                        hasLeadingSlash = true;
                    }
                    firstCharacter = false;
                }

                if (inEscape) {
                    if (ch == 'u') {
                        string unicodeSequence = GetCharacters(4);
                        if (unicodeSequence == null) {
                            throw new FormatException("Unterminated string literal.");
                        }
                        ch = (char)Int32.Parse(unicodeSequence, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
                    }
                    else if (ch == 'n') {
                        ch = '\n';
                    }
                    else if (ch == 't') {
                        ch = '\t';
                    }
                    else if (ch == 'r') {
                        ch = '\r';
                    }

                    sb.Append(ch);
                    inEscape = false;
                    continue;
                }

                if (ch == '\\') {
                    inEscape = true;
                    continue;
                }

                if (ch == endQuoteCharacter) {
                    return sb.ToString();
                }

                sb.Append(ch);
            }
        }

Same methods

JsonReader::ReadString ( ) : string