本文整理匯總了C#中System.IO.StringReader.ReadTo方法的典型用法代碼示例。如果您正苦於以下問題:C# StringReader.ReadTo方法的具體用法?C# StringReader.ReadTo怎麽用?C# StringReader.ReadTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.StringReader
的用法示例。
在下文中一共展示了StringReader.ReadTo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: NextToken
private Token NextToken(StringReader reader)
{
Skip(reader);
string result = string.Empty;
int c = reader.Peek();
if (c == options.DelimiterCharacter)
{
reader.Read();
return new Token(TokenType.Token);
}
else
{
if (IsQuoteCharacter(c))
{
result = ReadQuoted(reader);
Skip(reader);
if (IsEndOfStream(reader.Peek()))
{
return new Token(TokenType.EndOfRecord, result);
}
if (IsDelimiter(reader.Peek()))
{
reader.Read();
}
return new Token(TokenType.Token, result);
}
if (IsEndOfStream(c))
{
return new Token(TokenType.EndOfRecord);
}
else
{
result = reader.ReadTo(options.DelimiterCharacter).Trim();
Skip(reader);
if (IsEndOfStream(reader.Peek()))
{
return new Token(TokenType.EndOfRecord, result);
}
if(IsDelimiter(reader.Peek()))
{
reader.Read();
}
return new Token(TokenType.Token, result);
}
}
}
示例2: ReadQuoted
private string ReadQuoted(StringReader reader)
{
reader.Read();
string result = reader.ReadTo(options.QuoteCharacter);
reader.Read();
if (reader.Peek() != options.QuoteCharacter)
{
return result;
}
StringBuilder buffer = new StringBuilder(result);
do
{
buffer.Append((char)reader.Read());
buffer.Append(reader.ReadTo(options.QuoteCharacter));
reader.Read();
} while (reader.Peek() == options.QuoteCharacter);
return buffer.ToString();
}