本文整理匯總了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