本文整理汇总了C#中System.IO.StringReader.RemoveFromEnd方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.RemoveFromEnd方法的具体用法?C# StringReader.RemoveFromEnd怎么用?C# StringReader.RemoveFromEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringReader
的用法示例。
在下文中一共展示了StringReader.RemoveFromEnd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadStringLiteral
/// <summary>
/// Reads string-literal(stores it to reader 'r') and continuing fetch line.
/// </summary>
/// <param name="imap">IMAP client.</param>
/// <param name="r">String reader.</param>
/// <param name="callback">Fetch completion callback.</param>
/// <returns>Returns true if completed asynchronously or false if completed synchronously.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>imap</b>,<b>r</b> or <b>callback</b> is null reference.</exception>
private bool ReadStringLiteral(IMAP_Client imap,StringReader r,EventHandler<EventArgs<Exception>> callback)
{
if(imap == null){
throw new ArgumentNullException("imap");
}
if(r == null){
throw new ArgumentNullException("r");
}
if(callback == null){
throw new ArgumentNullException("callback");
}
if(r.SourceString.EndsWith("}") && r.SourceString.IndexOf("{") > -1){
MemoryStream stream = new MemoryStream();
string size = r.SourceString.Substring(r.SourceString.LastIndexOf("{") + 1,r.SourceString.Length - r.SourceString.LastIndexOf("{") - 2);
// Remove {n} from string.
r.RemoveFromEnd(r.SourceString.Length - r.SourceString.LastIndexOf('{'));
IMAP_Client.ReadStringLiteralAsyncOP op = new IMAP_Client.ReadStringLiteralAsyncOP(stream,Convert.ToInt32(size));
op.CompletedAsync += delegate(object sender,EventArgs<IMAP_Client.ReadStringLiteralAsyncOP> e){
try{
// Read string literal failed.
if(op.Error != null){
callback(this,new EventArgs<Exception>(op.Error));
}
else{
// Append string-literal to fetch reader.
r.AppendString(TextUtils.QuoteString(Encoding.UTF8.GetString(stream.ToArray())));
// Read next fetch line completed synchronously.
if(!ReadNextFetchLine(imap,r,callback)){
ParseDataItems(imap,r,callback);
}
}
}
catch(Exception x){
callback(this,new EventArgs<Exception>(x));
}
finally{
op.Dispose();
}
};
// Read string literal completed sync.
if(!imap.ReadStringLiteralAsync(op)){
try{
// Read string literal failed.
if(op.Error != null){
callback(this,new EventArgs<Exception>(op.Error));
return true;
}
else{
// Append string-literal to fetch reader.
r.AppendString(TextUtils.QuoteString(Encoding.UTF8.GetString(stream.ToArray())));
return ReadNextFetchLine(imap,r,callback);
}
}
finally{
op.Dispose();
}
}
// Read string literal completed async.
else{
return true;
}
}
else{
throw new ParseException("No string-literal available '" + r.SourceString + "'.");
}
}