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


C# StringReader.StartsWith方法代码示例

本文整理汇总了C#中StringReader.StartsWith方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.StartsWith方法的具体用法?C# StringReader.StartsWith怎么用?C# StringReader.StartsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringReader的用法示例。


在下文中一共展示了StringReader.StartsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        /// <summary>
        /// Parses IMAP FETCH BODYSTRUCTURE from reader.
        /// </summary>
        /// <param name="r">Fetch reader.</param>
        /// <returns>Returns parsed bodystructure.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
        public static IMAP_t_Fetch_r_i_BodyStructure Parse(StringReader r)
        {
            if(r == null){
                throw new ArgumentNullException("r");
            }

            IMAP_t_Fetch_r_i_BodyStructure retVal = new IMAP_t_Fetch_r_i_BodyStructure();
            r.ReadToFirstChar();
            // We have multipart message
            if(r.StartsWith("(")){
                retVal.m_pMessage = IMAP_t_Fetch_r_i_BodyStructure_e_Multipart.Parse(r);
            }
            // We have single-part message.
            else{
                 retVal.m_pMessage = IMAP_t_Fetch_r_i_BodyStructure_e_SinglePart.Parse(r);
            }

            return retVal;
        }
开发者ID:DJGosnell,项目名称:LumiSoft.Net,代码行数:25,代码来源:IMAP_t_Fetch_r_i_BodyStructure.cs

示例2: Parse

        /// <summary>
        /// Parses namespace info from IMAP NAMESPACE response string.
        /// </summary>
        /// <param name="namespaceString">IMAP NAMESPACE response string.</param>
        /// <returns></returns>
        internal static IMAP_NamespacesInfo Parse(string namespaceString)
        {
            StringReader r = new StringReader(namespaceString);
            // Skip NAMESPACE
            r.ReadWord();

            IMAP_Namespace[] personalNamespaces   = null;
            IMAP_Namespace[] otherUsersNamespaces = null;
            IMAP_Namespace[] sharedNamespaces     = null;

            // Personal namespace
            r.ReadToFirstChar();
            if(r.StartsWith("(")){
                personalNamespaces = ParseNamespaces(r.ReadParenthesized());
            }
            // NIL, skip it.
            else{
                r.ReadWord();
            }

            // Users Shared namespace
            r.ReadToFirstChar();
            if(r.StartsWith("(")){
                otherUsersNamespaces = ParseNamespaces(r.ReadParenthesized());
            }
            // NIL, skip it.
            else{
                r.ReadWord();
            }

            // Shared namespace
            r.ReadToFirstChar();
            if(r.StartsWith("(")){
                sharedNamespaces = ParseNamespaces(r.ReadParenthesized());
            }
            // NIL, skip it.
            else{
                r.ReadWord();
            }

            return new IMAP_NamespacesInfo(personalNamespaces,otherUsersNamespaces,sharedNamespaces);
        }
开发者ID:Klaudit,项目名称:inbox2_desktop,代码行数:47,代码来源:IMAP_NamespacesInfo.cs

示例3: Parse

        /// <summary>
        /// Returns parsed IMAP SEARCH <b>AND</b> key group.
        /// </summary>
        /// <param name="r">String reader.</param>
        /// <returns>Returns parsed IMAP SEARCH <b>AND</b> key group.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
        /// <exception cref="ParseException">Is raised when parsing fails.</exception>
        public static IMAP_Search_Key_Group Parse(StringReader r)
        {
            if(r == null){
                throw new ArgumentNullException("r");
            }

            // Remove parenthesis, if any.
            if(r.StartsWith("(")){
                r = new StringReader(r.ReadParenthesized());
            }

            IMAP_Search_Key_Group retVal = new IMAP_Search_Key_Group();

            r.ReadToFirstChar();
            while(r.Available > 0){
                retVal.m_pKeys.Add(IMAP_Search_Key.ParseKey(r));
            }

            return retVal;
        }
开发者ID:andreikalatsei,项目名称:milskype,代码行数:27,代码来源:IMAP_Search_Key_Group.cs

示例4: Parse

        /// <summary>
        /// Parses "alert-param" from specified reader.
        /// </summary>
        /// <param name="reader">Reader from where to parse.</param>
        /// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
        /// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
        public override void Parse(StringReader reader)
        {
            /* 
                alert-param = LAQUOT absoluteURI RAQUOT *( SEMI generic-param )
            */

            if(reader == null){
                throw new ArgumentNullException("reader");
            }
            
            // Parse uri
            // Read to LAQUOT
            reader.ReadToFirstChar();
            if(!reader.StartsWith("<")){
                throw new SIP_ParseException("Invalid Alert-Info value, Uri not between <> !");
            }
            m_Uri = reader.ReadParenthesized();

            // Parse parameters
            ParseParameters(reader);
        }
开发者ID:DJGosnell,项目名称:LumiSoft.Net,代码行数:27,代码来源:SIP_t_AlertParam.cs

示例5: Parse

        /// <summary>
        /// Parses "error-uri" from specified reader.
        /// </summary>
        /// <param name="reader">Reader from where to parse.</param>
        /// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
        /// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
        public override void Parse(StringReader reader)
        {
            /* 
                Error-Info = "Error-Info" HCOLON error-uri *(COMMA error-uri)
                error-uri  = LAQUOT absoluteURI RAQUOT *( SEMI generic-param )
            */

            if(reader == null){
                throw new ArgumentNullException("reader");
            }
            
            // Parse uri
            // Read to LAQUOT
            reader.QuotedReadToDelimiter('<');
            if(!reader.StartsWith("<")){
                throw new SIP_ParseException("Invalid 'error-uri' value, Uri not between <> !");
            }

            // Parse parameters
            ParseParameters(reader);
        }
开发者ID:iraychen,项目名称:LumiSoft.Net,代码行数:27,代码来源:SIP_t_ErrorUri.cs

示例6: Parse

        /// <summary>
        /// Parses search key from current position.
        /// </summary>
        /// <param name="reader"></param>
        public void Parse(StringReader reader)
        {
            //Remove spaces from string start
            reader.ReadToFirstChar();

            if (reader.StartsWith("("))
            {
                reader = new StringReader(reader.ReadParenthesized().Trim());
            }

            //--- Start parsing search keys --------------//
            while (reader.Available > 0)
            {
                object searchKey = ParseSearchKey(reader);
                if (searchKey != null)
                {
                    m_pSearchKeys.Add(searchKey);
                }
            }
            //--------------------------------------------//			
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:25,代码来源:IMAP_SearchGroup.cs

示例7: Parse

        /// <summary>
        /// Parses PERMANENTFLAGS optional response from string.
        /// </summary>
        /// <param name="r">PERMANENTFLAGS optional response reader.</param>
        /// <returns>Returns PERMANENTFLAGS optional response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
        public new static IMAP_t_orc_PermanentFlags Parse(StringReader r)
        {
            if(r == null){
                throw new ArgumentNullException("r");
            }

            if(!r.StartsWith("[PERMANENTFLAGS",false)){
                throw new ArgumentException("Invalid PERMANENTFLAGS response value.","r");
            }

            // Read [
            r.ReadSpecifiedLength(1);
            // Read PERMANENTFLAGS
            r.ReadWord();
            r.ReadToFirstChar();
            string[] flags = r.ReadParenthesized().Split(' ');
            // Read ]
            r.ReadSpecifiedLength(1);

            return new IMAP_t_orc_PermanentFlags(flags);
        }
开发者ID:DJGosnell,项目名称:LumiSoft.Net,代码行数:27,代码来源:IMAP_t_orc_PermanentFlags.cs

示例8: Parse

        /// <summary>
        /// Parses "info" from specified reader.
        /// </summary>
        /// <param name="reader">Reader from where to parse.</param>
        /// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
        /// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
        public override void Parse(StringReader reader)
        {
            /*
                Call-Info  = "Call-Info" HCOLON info *(COMMA info)
                info       = LAQUOT absoluteURI RAQUOT *( SEMI info-param)
                info-param = ( "purpose" EQUAL ( "icon" / "info" / "card" / token ) ) / generic-param
            */

            if(reader == null){
                throw new ArgumentNullException("reader");
            }
            
            // Parse uri
            // Read to LAQUOT
            reader.QuotedReadToDelimiter('<');
            if(!reader.StartsWith("<")){
                throw new SIP_ParseException("Invalid Alert-Info value, Uri not between <> !");
            }

            // Parse parameters
            ParseParameters(reader);
        }
开发者ID:iraychen,项目名称:LumiSoft.Net,代码行数:28,代码来源:SIP_t_Info.cs

示例9: ParseNamespaces

        private static IMAP_Namespace[] ParseNamespaces(string val)
        {
            StringReader r = new StringReader(val);
            r.ReadToFirstChar();

            List<IMAP_Namespace> namespaces = new List<IMAP_Namespace>();
            while (r.StartsWith("("))
            {
                namespaces.Add(ParseNamespace(r.ReadParenthesized()));
            }

            return namespaces.ToArray();
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:13,代码来源:IMAP_NamespacesInfo.cs

示例10: ParseKey

        /// <summary>
        /// Parses one search key or search key group.
        /// </summary>
        /// <param name="r">String reader.</param>
        /// <returns>Returns one parsed search key or search key group.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
        /// <exception cref="ParseException">Is raised when parsing fails.</exception>
        internal static IMAP_Search_Key ParseKey(StringReader r)
        {
            if(r == null){
                throw new ArgumentNullException("r");
            }

            r.ReadToFirstChar();

            // Keys group
            if(r.StartsWith("(",false)){
                return IMAP_Search_Key_Group.Parse(new StringReader(r.ReadParenthesized()));
            }
            // ANSWERED
            else if(r.StartsWith("ANSWERED",false)){
                return IMAP_Search_Key_Answered.Parse(r);
            }
            // BCC
            else if(r.StartsWith("BCC",false)){
                return IMAP_Search_Key_Bcc.Parse(r);
            }
            // BEFORE
            else if(r.StartsWith("BEFORE",false)){
                return IMAP_Search_Key_Before.Parse(r);
            }
            // BODY
            else if(r.StartsWith("BODY",false)){
                return IMAP_Search_Key_Body.Parse(r);
            }
            // CC
            else if(r.StartsWith("CC",false)){
                return IMAP_Search_Key_Cc.Parse(r);
            }
            // DELETED
            else if(r.StartsWith("DELETED",false)){
                return IMAP_Search_Key_Deleted.Parse(r);
            }
            // DRAFT
            else if(r.StartsWith("DRAFT",false)){
                return IMAP_Search_Key_Draft.Parse(r);
            }
            // FLAGGED
            else if(r.StartsWith("FLAGGED",false)){
                return IMAP_Search_Key_Flagged.Parse(r);
            }
            // FROM
            else if(r.StartsWith("FROM",false)){
                return IMAP_Search_Key_From.Parse(r);
            }
            // HEADER
            else if(r.StartsWith("HEADER",false)){
                return IMAP_Search_Key_Header.Parse(r);
            }
            // KEYWORD
            else if(r.StartsWith("KEYWORD",false)){
                return IMAP_Search_Key_Keyword.Parse(r);
            }
            // LARGER
            else if(r.StartsWith("LARGER",false)){
                return IMAP_Search_Key_Larger.Parse(r);
            }
            // NEW
            else if(r.StartsWith("NEW",false)){
                return IMAP_Search_Key_New.Parse(r);
            }
            // NOT
            else if(r.StartsWith("NOT",false)){
                return IMAP_Search_Key_Not.Parse(r);
            }
            // OLD
            else if(r.StartsWith("OLD",false)){
                return IMAP_Search_Key_Old.Parse(r);
            }
            // ON
            else if(r.StartsWith("ON",false)){
                return IMAP_Search_Key_On.Parse(r);
            }
            // OR
            else if(r.StartsWith("OR",false)){
                return IMAP_Search_Key_Or.Parse(r);
            }
            // RECENT
            else if(r.StartsWith("RECENT",false)){
                return IMAP_Search_Key_Recent.Parse(r);
            }
            // SEEN
            else if(r.StartsWith("SEEN",false)){
                return IMAP_Search_Key_Seen.Parse(r);
            }
            // SENTBEFORE
            else if(r.StartsWith("SENTBEFORE",false)){
                return IMAP_Search_Key_SentBefore.Parse(r);
            }
            // SENTON
//.........这里部分代码省略.........
开发者ID:andreikalatsei,项目名称:milskype,代码行数:101,代码来源:IMAP_Search_Key.cs

示例11: Parse

        /// <summary>
        /// Parses entity and it's child entities.
        /// </summary>
        internal void Parse(string text)
        {
            StringReader r = new StringReader(text);
            r.ReadToFirstChar();

            // If starts with ( then multipart/xxx, otherwise normal single part entity
            if (r.StartsWith("("))
            {
                // Entities are (entity1)(entity2)(...) <SP> ContentTypeSubType
                while (r.StartsWith("("))
                {
                    IMAP_BODY_Entity entity = new IMAP_BODY_Entity();
                    entity.Parse(r.ReadParenthesized());
                    entity.m_pParentEntity = this;
                    m_pChildEntities.Add(entity);

                    r.ReadToFirstChar();
                }

                // Read multipart values. (nestedMimeEntries) contentTypeSubMediaType
                string contentTypeSubMediaType = r.ReadWord();

                m_pContentType = MimeUtils.ParseMediaType("multipart/" + contentTypeSubMediaType);
            }
            else
            {
                // Basic fields for non-multipart
                // contentTypeMainMediaType contentTypeSubMediaType (conentTypeParameters) contentID contentDescription contentEncoding contentSize [envelope] [contentLine]

                // Content-Type
                string contentTypeMainMediaType = r.ReadWord();
                string contentTypeSubMediaType = r.ReadWord();
                if (contentTypeMainMediaType.ToUpper() != "NIL" && contentTypeSubMediaType.ToUpper() != "NIL")
                {
                    m_pContentType =
                        MimeUtils.ParseMediaType(contentTypeMainMediaType + "/" + contentTypeSubMediaType);
                }

                // Content-Type header field parameters
                // Parameters syntax: "name" <SP> "value" <SP> "name" <SP> "value" <SP> ... .
                r.ReadToFirstChar();
                string conentTypeParameters = "NIL";
                if (r.StartsWith("("))
                {
                    conentTypeParameters = r.ReadParenthesized();

                    StringReader contentTypeParamReader =
                        new StringReader(MimeUtils.DecodeWords(conentTypeParameters));
                    List<HeaderFieldParameter> parameters = new List<HeaderFieldParameter>();
                    while (contentTypeParamReader.Available > 0)
                    {
                        string parameterName = contentTypeParamReader.ReadWord();
                        string parameterValue = contentTypeParamReader.ReadWord();

                        parameters.Add(new HeaderFieldParameter(parameterName, parameterValue));
                    }
                    m_pContentTypeParams = parameters.ToArray();
                }
                else
                {
                    // Skip NIL
                    r.ReadWord();
                }

                // Content-ID:
                string contentID = r.ReadWord();
                if (contentID.ToUpper() != "NIL")
                {
                    m_ContentID = contentID;
                }

                // Content-Description:
                string contentDescription = r.ReadWord();
                if (contentDescription.ToUpper() != "NIL")
                {
                    m_ContentDescription = contentDescription;
                }

                // Content-Transfer-Encoding:
                string contentEncoding = r.ReadWord();
                if (contentEncoding.ToUpper() != "NIL")
                {
                    m_ContentEncoding = MimeUtils.ParseContentTransferEncoding(contentEncoding);
                }

                // Content Encoded data size in bytes
                string contentSize = r.ReadWord();
                if (contentSize.ToUpper() != "NIL")
                {
                    m_ContentSize = Convert.ToInt32(contentSize);
                }

                // Only for ContentType message/rfc822
                if (ContentType == MediaType_enum.Message_rfc822)
                {
                    r.ReadToFirstChar();

//.........这里部分代码省略.........
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:101,代码来源:IMAP_BODY_Entity.cs

示例12: Parse

        /// <summary>
        /// Parses "name-addr" or "addr-spec" from specified reader.
        /// </summary>
        /// <param name="reader">Reader from where to parse.</param>
        /// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
        /// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
        public void Parse(StringReader reader)
        {
            /* RFC 3261.
                name-addr =  [ display-name ] LAQUOT addr-spec RAQUOT
                addr-spec =  SIP-URI / SIPS-URI / absoluteURI
            */

            if(reader == null){
                throw new ArgumentNullException("reader");
            }

            reader.ReadToFirstChar();
                        
            // LAQUOT addr-spec RAQUOT
            if(reader.StartsWith("<")){
                m_pUri = AbsoluteUri.Parse(reader.ReadParenthesized());
            }
            else{
                // Read while we get "<","," or EOF.
                StringBuilder buf = new StringBuilder();
                while(true){
                    buf.Append(reader.ReadToFirstChar());

                    string word = reader.ReadWord();
                    if(string.IsNullOrEmpty(word)){
                        break;
                    }
                    else{
                        buf.Append(word);
                    }
                }

                reader.ReadToFirstChar();

                // name-addr
                if(reader.StartsWith("<")){
                    m_DisplayName = buf.ToString().Trim();
                    m_pUri        = AbsoluteUri.Parse(reader.ReadParenthesized());
                }
                // addr-spec
                else{
                    m_pUri = AbsoluteUri.Parse(buf.ToString());
                }
            }            
        }
开发者ID:dioptre,项目名称:nkd,代码行数:51,代码来源:SIP_t_NameAddress.cs

示例13: Start

            /// <summary>
            /// Starts reading FETCH response.
            /// </summary>
            public void Start()
            {
                // * seqNo FETCH 1data-item/(1*data-item)

                int seqNo = Convert.ToInt32(m_FetchLine.Split(' ')[1]);

                // Notify that current message has changed.
                m_pHandler.SetCurrentSeqNo(seqNo);
                m_pHandler.OnNextMessage();

                m_pFetchReader = new StringReader(m_FetchLine.Split(new char[]{' '},4)[3]);
                if(m_pFetchReader.StartsWith("(")){
                    m_pFetchReader.ReadSpecifiedLength(1);
                }

                // Read data-items.
                while(m_pFetchReader.Available > 0){
                    m_pFetchReader.ReadToFirstChar();
                //*
                    #region BODY

                    if(m_pFetchReader.StartsWith("BODY ",false)){
                    }

                    #endregion

                    #region BODY[<section>]<<origin octet>>

                    else if(m_pFetchReader.StartsWith("BODY[",false)){
                        // Eat BODY word.
                        m_pFetchReader.ReadWord();

                        // Read body-section.
                        string section = m_pFetchReader.ReadParenthesized();

                        // Read origin if any.
                        int offset = -1;
                        if(m_pFetchReader.StartsWith("<")){
                            offset = Convert.ToInt32(m_pFetchReader.ReadParenthesized().Split(' ')[0]);
                        }

                        // Get Message store stream.
                        IMAP_Client_Fetch_Body_EArgs eArgs = new IMAP_Client_Fetch_Body_EArgs(section,offset);
                        m_pHandler.OnBody(eArgs);

                        // We don't have BODY[].
                        m_pFetchReader.ReadToFirstChar();
                        if(m_pFetchReader.StartsWith("NIL",false)){
                            // Eat NIL.
                            m_pFetchReader.ReadWord();
                        }
                        // BODY[] value is returned as string-literal.
                        else if(m_pFetchReader.StartsWith("{",false)){
                            if(eArgs.Stream == null){
                                m_pImap.ReadStringLiteral(Convert.ToInt32(m_pFetchReader.ReadParenthesized()),new JunkingStream());
                            }
                            else{
                                m_pImap.ReadStringLiteral(Convert.ToInt32(m_pFetchReader.ReadParenthesized()),eArgs.Stream);
                            }

                            // Read continuing FETCH line.
                            m_pFetchReader = new StringReader(m_pImap.ReadLine());
                        }
                        // BODY[] is quoted-string.
                        else{
                            m_pFetchReader.ReadWord();
                        }

                        // Notify that message storing has completed.
                        eArgs.OnStoringCompleted();
                    }

                    #endregion
                //*
                    #region BODYSTRUCTURE

                    else if(m_pFetchReader.StartsWith("BODYSTRUCTURE ",false)){
                    }

                    #endregion

                    #region ENVELOPE

                    else if(m_pFetchReader.StartsWith("ENVELOPE ",false)){
                        m_pHandler.OnEnvelope(IMAP_Envelope.Parse(this));
                    }

                    #endregion

                    #region  FLAGS

                    else if(m_pFetchReader.StartsWith("FLAGS ",false)){
                        // Eat FLAGS word.
                        m_pFetchReader.ReadWord();

                        string   flagsList = m_pFetchReader.ReadParenthesized();
                        string[] flags     = new string[0];
//.........这里部分代码省略.........
开发者ID:andreikalatsei,项目名称:milskype,代码行数:101,代码来源:IMAP_Client.cs

示例14: Parse

        /// <summary>
        /// Parses "name-addr" or "addr-spec" from specified reader.
        /// </summary>
        /// <param name="reader">Reader from where to parse.</param>
        /// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
        /// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
        public void Parse(StringReader reader)
        {
            /* RFC 3261.
                name-addr =  [ display-name ] LAQUOT addr-spec RAQUOT
                addr-spec =  SIP-URI / SIPS-URI / absoluteURI
            */

            if(reader == null){
                throw new ArgumentNullException("reader");
            }

            reader.ReadToFirstChar();

            // LAQUOT addr-spec RAQUOT
            if(reader.StartsWith("<")){
                m_Uri = reader.ReadParenthesized();
            }
            else{
                string word = reader.ReadWord();
                if(word == null){
                    throw new SIP_ParseException("Invalid 'name-addr' or 'addr-spec' value !");
                }

                reader.ReadToFirstChar();

                // name-addr
                if(reader.StartsWith("<")){
                    m_DisplayName = word;
                    m_Uri         = reader.ReadParenthesized();
                }
                // addr-spec
                else{
                    m_Uri = word;
                }
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:42,代码来源:SIP_t_NameAddress.cs

示例15: Parse

        /// <summary>
        /// Parses entity and it's child entities.
        /// </summary>
        internal void Parse(string text)
        {
            StringReader r = new StringReader(text);
            r.ReadToFirstChar();

            // If starts with ( then multipart/xxx, otherwise normal single part entity
            if(r.StartsWith("(")){
                // Entities are (entity1)(entity2)(...) <SP> ContentTypeSubType
                while(r.StartsWith("(")){
                    IMAP_BODY_Entity entity = new IMAP_BODY_Entity();
                    entity.Parse(r.ReadParenthesized());
                    entity.m_pParentEntity = this;
                    m_pChildEntities.Add(entity);

                    r.ReadToFirstChar();
                }
                
                // Read multipart values. (nestedMimeEntries) contentTypeSubMediaType
                string contentTypeSubMediaType = r.ReadWord();

                m_pContentType = new MIME_h_ContentType("multipart/" + contentTypeSubMediaType);
            }
            else{
                // Basic fields for non-multipart
				// contentTypeMainMediaType contentTypeSubMediaType (conentTypeParameters) contentID contentDescription contentEncoding contentSize [envelope] [contentLine]

                // Content-Type
                string contentTypeMainMediaType = r.ReadWord();
                string contentTypeSubMediaType  = r.ReadWord();
                if(contentTypeMainMediaType.ToUpper() != "NIL" && contentTypeSubMediaType.ToUpper() != "NIL"){
                    m_pContentType = new MIME_h_ContentType(contentTypeMainMediaType + "/" + contentTypeSubMediaType);
                }

                // Content-Type header field parameters
                // Parameters syntax: "name" <SP> "value" <SP> "name" <SP> "value" <SP> ... .
                r.ReadToFirstChar();
                string conentTypeParameters = "NIL";
                if(r.StartsWith("(")){
                    conentTypeParameters = r.ReadParenthesized();

                    StringReader contentTypeParamReader = new StringReader(conentTypeParameters);
                    while(contentTypeParamReader.Available > 0){
                        string parameterName  = contentTypeParamReader.ReadWord();
                        string parameterValue = MIME_Encoding_EncodedWord.DecodeS(contentTypeParamReader.ReadWord());

                        m_pContentType.Parameters[parameterName] = parameterValue;
                    }
                }
                else{
                    // Skip NIL
                    r.ReadWord();
                }

                // Content-ID:
                string contentID = r.ReadWord();
                if(contentID.ToUpper() != "NIL"){
                    m_ContentID = contentID;
                }

                // Content-Description:
                string contentDescription = r.ReadWord();
                if(contentDescription.ToUpper() != "NIL"){
                    m_ContentDescription = contentDescription;
                }

                // Content-Transfer-Encoding:
                string contentEncoding = r.ReadWord();
                if(contentEncoding.ToUpper() != "NIL"){                   
                    m_ContentEncoding = contentEncoding;
                }

                // Content Encoded data size in bytes
                string contentSize = r.ReadWord();
                if(contentSize.ToUpper() != "NIL"){
                    m_ContentSize = Convert.ToInt32(contentSize);
                }

                // Only for ContentType message/rfc822
                if(string.Equals(this.ContentType.TypeWithSubype,MIME_MediaTypes.Message.rfc822,StringComparison.InvariantCultureIgnoreCase)){
                    r.ReadToFirstChar();
 
                    // envelope
                    if(r.StartsWith("(")){
                        r.ReadParenthesized();
                    }
                    else{
                        // Skip NIL, ENVELOPE wasn't included
                        r.ReadWord();
                    }

                    // TODO:
                    // BODYSTRUCTURE

                    // contentLine
                }

                // Only for ContentType text/xxx
//.........这里部分代码省略.........
开发者ID:dioptre,项目名称:nkd,代码行数:101,代码来源:IMAP_BODY_Entity.cs


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