LSharp.Reader.StringReader C# (CSharp) Method

StringReader() public static method

public static StringReader ( TextReader textReader ) : Object
textReader TextReader
return Object
        public static Object StringReader(TextReader textReader)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool done = false;
            int c;

            do
            {
                c = textReader.Read();

                if (c == -1) throw new Exception("EOF Reached");

                if (c == '\"') done = true;

                if (c == '\\')	// Deal with Escape characters ..
                {
                    c = textReader.Read();
                    if (c == -1)
                    {
                        throw new Exception("Read error - eof found before matching: \"");
                    }
                    switch (c)
                    {
                        case 't':
                            c = '\t';
                            break;
                        case 'r':
                            c = '\r';
                            break;
                        case 'n':
                            c = '\n';
                            break;
                        case '\\':
                            break;
                        case '"':
                            break;
                        default:
                            throw new Exception("Unsupported escape character: \\" + (Char)c);
                    }
                }

                if (!done)
                    stringBuilder.Append((char)c);

            } while (!done);

            return stringBuilder.ToString();
        }