本文整理汇总了C#中System.IO.StringReader.AppenString方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.AppenString方法的具体用法?C# StringReader.AppenString怎么用?C# StringReader.AppenString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringReader
的用法示例。
在下文中一共展示了StringReader.AppenString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchMessages
//.........这里部分代码省略.........
#endregion
#region ENVELOPE (<envelope-string>)
else if (r.StartsWith("ENVELOPE", false))
{
// Remove ENVELOPE word from reply
r.ReadSpecifiedLength("ENVELOPE".Length);
r.ReadToFirstChar();
/*
Handle string literals {count-to-read}<CRLF>data(length = count-to-read).
(string can be quoted string or literal)
Loop while get envelope,invalid response or timeout.
*/
while (true)
{
try
{
envelope = r.ReadParenthesized();
break;
}
catch (Exception x)
{
string s = r.ReadToEnd();
/* partial_envelope {count-to-read}
Example: ENVELOPE ("Mon, 03 Apr 2006 10:10:10 GMT" {35}
*/
if (s.EndsWith("}"))
{
// Get partial envelope and append it back to reader
r.AppenString(s.Substring(0, s.LastIndexOf('{')));
// Read remaining envelope and append it to reader.
int countToRead = Convert.ToInt32(s.Substring(s.LastIndexOf('{') + 1, s.LastIndexOf('}') - s.LastIndexOf('{') - 1));
string reply = this.TcpStream.ReadFixedCountString(countToRead);
LogAddRead(countToRead, reply);
r.AppenString(TextUtils.QuoteString(reply));
// Read fetch continuing line.
this.TcpStream.ReadLine(args, false);
if (args.Error != null)
{
throw args.Error;
}
line = args.LineUtf8;
LogAddRead(args.BytesInBuffer, line);
r.AppenString(line);
}
// Unexpected response
else
{
throw x;
}
}
}
}
#endregion
#region BODYSTRUCTURE (<bodystructure-string>)
else if (r.StartsWith("BODYSTRUCTURE", false))
{
示例2: FetchMessages
//.........这里部分代码省略.........
else{
internalDate = word;
}
}
#endregion
#region ENVELOPE (<envelope-string>)
else if(r.StartsWith("ENVELOPE",false)){
// Remove ENVELOPE word from reply
r.ReadSpecifiedLength("ENVELOPE".Length);
r.ReadToFirstChar();
/*
Handle string literals {count-to-read}<CRLF>data(length = count-to-read).
(string can be quoted string or literal)
Loop while get envelope,invalid response or timeout.
*/
while(true){
try{
envelope = r.ReadParenthesized();
break;
}
catch(Exception x){
string s = r.ReadToEnd();
/* partial_envelope {count-to-read}
Example: ENVELOPE ("Mon, 03 Apr 2006 10:10:10 GMT" {35}
*/
if(s.EndsWith("}")){
// Get partial envelope and append it back to reader
r.AppenString(s.Substring(0,s.LastIndexOf('{')));
// Read remaining envelope and append it to reader
int countToRead = Convert.ToInt32(s.Substring(s.LastIndexOf('{') + 1,s.LastIndexOf('}') - s.LastIndexOf('{') - 1));
MemoryStream strm = new MemoryStream();
m_pSocket.ReadSpecifiedLength(countToRead,strm);
r.AppenString(TextUtils.QuoteString(System.Text.Encoding.Default.GetString(strm.ToArray())));
// Read fetch continuing line
r.AppenString(m_pSocket.ReadLine(50000));
}
// Unexpected response
else{
throw x;
}
}
}
}
#endregion
#region BODYSTRUCTURE (<bodystructure-string>)
else if(r.StartsWith("BODYSTRUCTURE",false)){
// Remove BODYSTRUCTURE word from reply
r.ReadSpecifiedLength("BODYSTRUCTURE".Length);
r.ReadToFirstChar();
bodystructure = r.ReadParenthesized();
}
#endregion