当前位置: 首页>>代码示例>>C#>>正文


C# StringReader.EndsWith方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:DJGosnell,项目名称:LumiSoft.Net,代码行数:62,代码来源:IMAP_t_Fetch_r_i_Envelope.cs


注:本文中的StringReader.EndsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。