本文整理汇总了C#中StringReader.EndsWith方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.EndsWith方法的具体用法?C# StringReader.EndsWith怎么用?C# StringReader.EndsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringReader
的用法示例。
在下文中一共展示了StringReader.EndsWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadAddresses
/// <summary>
/// Reads parenthesized list of addresses.
/// </summary>
/// <param name="r">String reader.</param>
/// <returns>Returns read addresses.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
private static Mail_t_Address[] ReadAddresses(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
/* RFC 3501 7.4.2.
An address structure is a parenthesized list that describes an
electronic mail address. The fields of an address structure
are in the following order: personal name, [SMTP]
at-domain-list (source route), mailbox name, and host name.
[RFC-2822] group syntax is indicated by a special form of
address structure in which the host name field is NIL. If the
mailbox name field is also NIL, this is an end of group marker
(semi-colon in RFC 822 syntax). If the mailbox name field is
non-NIL, this is a start of group marker, and the mailbox name
field holds the group name phrase.
*/
r.ReadToFirstChar();
if(r.StartsWith("NIL",false)){
r.ReadWord();
return null;
}
else{
List<Mail_t_Address> retVal = new List<Mail_t_Address>();
StringReader addressesReader = new StringReader(r.ReadParenthesized());
addressesReader.ReadToFirstChar();
while(addressesReader.Available > 0){
// Eat address starting "(".
if(addressesReader.StartsWith("(")){
addressesReader.ReadSpecifiedLength(1);
}
string personalName = ReadAndDecodeWord(addressesReader);
string atDomainList = addressesReader.ReadWord();
string mailboxName = addressesReader.ReadWord();
string hostName = addressesReader.ReadWord();
retVal.Add(new Mail_t_Mailbox(personalName,mailboxName + "@" + hostName));
// Eat address ending ")".
if(addressesReader.EndsWith(")")){
addressesReader.ReadSpecifiedLength(1);
}
addressesReader.ReadToFirstChar();
}
return retVal.ToArray();
}
}