本文整理汇总了C#中MailKit.Net.Imap.ImapEngine.ParseHeaders方法的典型用法代码示例。如果您正苦于以下问题:C# ImapEngine.ParseHeaders方法的具体用法?C# ImapEngine.ParseHeaders怎么用?C# ImapEngine.ParseHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailKit.Net.Imap.ImapEngine
的用法示例。
在下文中一共展示了ImapEngine.ParseHeaders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchSummaryItems
//.........这里部分代码省略.........
token = engine.ReadToken (ic.CancellationToken);
if (token.Type == ImapTokenType.CloseParen)
break;
// the header field names will generally be atoms or qstrings but may also be literals
switch (token.Type) {
case ImapTokenType.Literal:
engine.ReadLiteral (ic.CancellationToken);
break;
case ImapTokenType.QString:
case ImapTokenType.Atom:
break;
default:
throw ImapEngine.UnexpectedToken (ImapEngine.GenericItemSyntaxErrorFormat, atom, token);
}
} while (true);
} else if (token.Type != ImapTokenType.Atom) {
throw ImapEngine.UnexpectedToken (ImapEngine.GenericItemSyntaxErrorFormat, atom, token);
}
} while (true);
if (token.Type != ImapTokenType.CloseBracket)
throw ImapEngine.UnexpectedToken (ImapEngine.GenericItemSyntaxErrorFormat, atom, token);
token = engine.ReadToken (ic.CancellationToken);
if (token.Type != ImapTokenType.Literal)
throw ImapEngine.UnexpectedToken (ImapEngine.GenericItemSyntaxErrorFormat, atom, token);
summary.References = new MessageIdList ();
try {
summary.Headers = engine.ParseHeaders (engine.Stream, ic.CancellationToken);
} catch (FormatException) {
// consume any remaining literal data...
ReadLiteralData (engine, ic.CancellationToken);
summary.Headers = new HeaderList ();
}
if ((idx = summary.Headers.IndexOf (HeaderId.References)) != -1) {
var references = summary.Headers[idx];
var rawValue = references.RawValue;
foreach (var msgid in MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length))
summary.References.Add (msgid);
}
summary.Fields |= MessageSummaryItems.References;
} else {
summary.Fields |= MessageSummaryItems.Body;
try {
format = string.Format (ImapEngine.GenericItemSyntaxErrorFormat, "BODY", "{0}");
summary.Body = ImapUtils.ParseBody (engine, format, string.Empty, ic.CancellationToken);
} catch (ImapProtocolException ex) {
if (!ex.UnexpectedToken)
throw;
// Note: GMail's IMAP implementation sometimes replies with completely broken BODY values
// (see issue #32 for the `BODY ("ALTERNATIVE")` example), so to work around this nonsense,
// we need to drop the remainder of this line.
do {
token = engine.PeekToken (ic.CancellationToken);
if (token.Type == ImapTokenType.Eoln)