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


C# StringReader.ReadWord方法代码示例

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


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

示例1: Parse

        /// <summary>
        /// Parses "Timestamp" 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)
        {
            /* RFC 3261.
                Timestamp =  "Timestamp" HCOLON 1*(DIGIT) [ "." *(DIGIT) ] [ LWS delay ]
                    delay =  *(DIGIT) [ "." *(DIGIT) ]
            */

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

            // Get time
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("Invalid 'Timestamp' value, time is missing !");
            }
            m_Time = Convert.ToDecimal(word);

            // Get optional delay
            word = reader.ReadWord();
            if(word != null){
                m_Delay = Convert.ToDecimal(word);
            }
            else{
                m_Delay = 0;
            }
        }
开发者ID:CivilPol,项目名称:LumiSoft.Net,代码行数:33,代码来源:SIP_t_Timestamp.cs

示例2: Parse

        /// <summary>
        /// Parses media from "t" SDP message field.
        /// </summary>
        /// <param name="tValue">"t" SDP message field.</param>
        /// <returns></returns>
        public static SDP_Time Parse(string tValue)
        {
            // t=<start-time> <stop-time>
            
            long startTime = 0;
            long endTime   = 0;
 
            // Remove t=
            StringReader r = new StringReader(tValue);
            r.QuotedReadToDelimiter('=');

            //--- <start-time> ------------------------------------------------------------
            string word = r.ReadWord();
            if(word == null){
                throw new Exception("SDP message \"t\" field <start-time> value is missing !");
            }
            startTime = Convert.ToInt64(word);

            //--- <stop-time> -------------------------------------------------------------
            word = r.ReadWord();
            if(word == null){
                throw new Exception("SDP message \"t\" field <stop-time> value is missing !");
            }
            endTime = Convert.ToInt64(word);

            return new SDP_Time(startTime,endTime);
        }
开发者ID:dioptre,项目名称:nkd,代码行数:32,代码来源:SDP_Time.cs

示例3: Parse

        /// <summary>
        /// Parses media from "c" SDP message field.
        /// </summary>
        /// <param name="cValue">"m" SDP message field.</param>
        /// <returns></returns>
        public static SDP_Connection Parse(string cValue)
        {
            // c=<nettype> <addrtype> <connection-address>

            string netType          = "";
            string addrType         = "";
            string connectionAddress = "";

            // Remove c=
            StringReader r = new StringReader(cValue);
            r.QuotedReadToDelimiter('=');

            //--- <nettype> ------------------------------------------------------------
            string word = r.ReadWord();
            if(word == null){
                throw new Exception("SDP message \"c\" field <nettype> value is missing !");
            }
            netType = word;

            //--- <addrtype> -----------------------------------------------------------
            word = r.ReadWord();
            if(word == null){
                throw new Exception("SDP message \"c\" field <addrtype> value is missing !");
            }
            addrType = word;

            //--- <connection-address> -------------------------------------------------
            word = r.ReadWord();
            if(word == null){
                throw new Exception("SDP message \"c\" field <connection-address> value is missing !");
            }
            connectionAddress = word;

            return new SDP_Connection(netType,addrType,connectionAddress);
        }
开发者ID:dioptre,项目名称:nkd,代码行数:40,代码来源:SDP_Connection.cs

示例4: Parse

        /// <summary>
        /// Parses MYRIGHTS response from MYRIGHTS-response string.
        /// </summary>
        /// <param name="myRightsResponse">MYRIGHTS response line.</param>
        /// <returns>Returns parsed MYRIGHTS response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>myRightsResponse</b> is null reference.</exception>
        public static IMAP_Response_MyRights Parse(string myRightsResponse)
        {
            if(myRightsResponse == null){
                throw new ArgumentNullException("myRightsResponse");
            }

            /* RFC 4314 3.8. MYRIGHTS Response.
                Data:       mailbox name
                            rights

                The MYRIGHTS response occurs as a result of a MYRIGHTS command.  The
                first string is the mailbox name for which these rights apply.  The
                second string is the set of rights that the client has.

                Section 2.1.1 details additional server requirements related to
                handling of the virtual "d" and "c" rights.
             
                Example:    C: A003 MYRIGHTS INBOX
                            S: * MYRIGHTS INBOX rwiptsldaex
                            S: A003 OK Myrights complete
            */

            StringReader r = new StringReader(myRightsResponse);
            // Eat "*"
            r.ReadWord();
            // Eat "MYRIGHTS"
            r.ReadWord();

            string folder = IMAP_Utils.Decode_IMAP_UTF7_String(r.ReadWord(true));
            string rights = r.ReadToEnd().Trim();

            return new IMAP_Response_MyRights(folder,rights);
        }
开发者ID:iraychen,项目名称:LumiSoft.Net,代码行数:39,代码来源:IMAP_Response_MyRights.cs

示例5: Parse

        /// <summary>
        /// Parses LSUB response from lsub-response string.
        /// </summary>
        /// <param name="lSubResponse">LSub response string.</param>
        /// <returns>Returns parsed lsub response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>lSubResponse</b> is null reference.</exception>
        public static IMAP_r_u_LSub Parse(string lSubResponse)
        {
            if(lSubResponse == null){
                throw new ArgumentNullException("lSubResponse");
            }

            /* RFC 3501 7.2.3. LSUB Response.
                Contents:   name attributes
                            hierarchy delimiter
                            name

                The LSUB response occurs as a result of an LSUB command.  It
                returns a single name that matches the LSUB specification.  There
                can be multiple LSUB responses for a single LSUB command.  The
                data is identical in format to the LIST response.

                Example:    S: * LSUB () "." #news.comp.mail.misc
            */

            StringReader r = new StringReader(lSubResponse);
            // Eat "*"
            r.ReadWord();
            // Eat "LSUB"
            r.ReadWord();

            string attributes = r.ReadParenthesized();
            string delimiter  = r.ReadWord();
            string folder     = TextUtils.UnQuoteString(IMAP_Utils.DecodeMailbox(r.ReadToEnd().Trim()));

            return new IMAP_r_u_LSub(folder,delimiter[0],attributes == string.Empty ? new string[0] : attributes.Split(' '));
        }
开发者ID:CivilPol,项目名称:LumiSoft.Net,代码行数:37,代码来源:IMAP_r_u_LSub.cs

示例6: Parse

        /// <summary>
        /// Parses ENABLE response from enable-response string.
        /// </summary>
        /// <param name="enableResponse">Enable response string.</param>
        /// <returns>Returns parsed ENABLE response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>enableResponse</b> is null reference.</exception>
        public static IMAP_r_u_Enable Parse(string enableResponse)
        {
            if(enableResponse == null){
                throw new ArgumentNullException("enableResponse");
            }

            /* RFC 5161 4.  Formal Syntax
                The following syntax specification uses the Augmented Backus-Naur
                Form (ABNF) notation as specified in [RFC5234] including the core
                rules in Appendix B.1.  [RFC3501] defines the non-terminals
                "capability" and "command-any".

                Except as noted otherwise, all alphabetic characters are
                case-insensitive.  The use of upper or lower case characters to
                define token strings is for editorial clarity only.  Implementations
                MUST accept these strings in a case-insensitive fashion.

                    capability    =/ "ENABLE"
                    command-any   =/ "ENABLE" 1*(SP capability)
                    response-data =/ "*" SP enable-data CRLF
                    enable-data   = "ENABLED" *(SP capability)
            */

            StringReader r = new StringReader(enableResponse);
            // Eat "*"
            r.ReadWord();
            // Eat "ENABLED"
            r.ReadWord();

            return new IMAP_r_u_Enable(r.ReadToEnd().Split(' '));
        }
开发者ID:nbhopson,项目名称:QMail,代码行数:37,代码来源:IMAP_r_u_Enable.cs

示例7: Parse

        /// <summary>
        /// Parses STATUS response from status-response string.
        /// </summary>
        /// <param name="response">Satatus response string.</param>
        /// <returns>Returns parsed STATUS response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>response</b> is null reference.</exception>
        public static IMAP_r_u_Status Parse(string response)
        {
            if(response == null){
                throw new ArgumentNullException("response");
            }

            /* RFC 3501 7.2.4 STATUS Response.
                Contents:   name
                            status parenthesized list

                The STATUS response occurs as a result of an STATUS command.  It
                returns the mailbox name that matches the STATUS specification and
                the requested mailbox status information.

                Example:    S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292)
            */

            StringReader r = new StringReader(response);
            // Eat "*"
            r.ReadWord();
            // Eat "STATUS"
            r.ReadWord();
            
            int  messages  = 0;
            int  recent    = 0;
            long uidNext   = 0;
            long folderUid = 0;
            int  unseen    = 0;

            string   folder = TextUtils.UnQuoteString(IMAP_Utils.Decode_IMAP_UTF7_String(r.ReadWord()));
            string[] items  = r.ReadParenthesized().Split(' ');
            for(int i=0;i<items.Length;i+=2){
                if(items[i].Equals("MESSAGES",StringComparison.InvariantCultureIgnoreCase)){
                    messages = Convert.ToInt32(items[i + 1]);
                }
                else if(items[i].Equals("RECENT",StringComparison.InvariantCultureIgnoreCase)){
                    recent = Convert.ToInt32(items[i + 1]);
                }
                else if(items[i].Equals("UIDNEXT",StringComparison.InvariantCultureIgnoreCase)){
                    uidNext = Convert.ToInt64(items[i + 1]);
                }
                else if(items[i].Equals("UIDVALIDITY",StringComparison.InvariantCultureIgnoreCase)){
                    folderUid = Convert.ToInt64(items[i + 1]);
                }
                else if(items[i].Equals("UNSEEN",StringComparison.InvariantCultureIgnoreCase)){
                    unseen = Convert.ToInt32(items[i + 1]);
                }
            }

            return new IMAP_r_u_Status(folder,messages,recent,uidNext,folderUid,unseen);
        }
开发者ID:CivilPol,项目名称:LumiSoft.Net,代码行数:57,代码来源:IMAP_r_u_Status.cs

示例8: Parse

        /// <summary>
        /// Parses BYE response from bye-response string.
        /// </summary>
        /// <param name="byeResponse">Bye response string.</param>
        /// <returns>Returns parsed BYE response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>byeResponse</b> is null reference.</exception>
        public static IMAP_r_u_Bye Parse(string byeResponse)
        {
            if(byeResponse == null){
                throw new ArgumentNullException("byeResponse");
            }

            /* RFC 3501 7.1.5. BYE Response.
               Contents:   OPTIONAL response code
                           human-readable text

                  The BYE response is always untagged, and indicates that the server
                  is about to close the connection.  The human-readable text MAY be
                  displayed to the user in a status report by the client.  The BYE
                  response is sent under one of four conditions:

                     1) as part of a normal logout sequence.  The server will close
                        the connection after sending the tagged OK response to the
                        LOGOUT command.

                     2) as a panic shutdown announcement.  The server closes the
                        connection immediately.

                     3) as an announcement of an inactivity autologout.  The server
                        closes the connection immediately.

                     4) as one of three possible greetings at connection startup,
                        indicating that the server is not willing to accept a
                        connection from this client.  The server closes the
                        connection immediately.

                  The difference between a BYE that occurs as part of a normal
                  LOGOUT sequence (the first case) and a BYE that occurs because of
                  a failure (the other three cases) is that the connection closes
                  immediately in the failure case.  In all cases the client SHOULD
                  continue to read response data from the server until the
                  connection is closed; this will ensure that any pending untagged
                  or completion responses are read and processed.

               Example:    S: * BYE Autologout; idle for too long
            */

            StringReader r = new StringReader(byeResponse);
            // Eat "*"
            r.ReadWord();
            // Eat "BYE"
            r.ReadWord();

            return new IMAP_r_u_Bye(r.ReadToEnd());
        }
开发者ID:iraychen,项目名称:LumiSoft.Net,代码行数:55,代码来源:IMAP_r_u_Bye.cs

示例9: Parse

        /// <summary>
        /// Parses "Session-Expires" 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)
        {
            /*
                Session-Expires  = delta-seconds *(SEMI se-params)
                se-params        = refresher-param / generic-param
                refresher-param  = "refresher" EQUAL  ("uas" / "uac")      
            */

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

            // delta-seconds
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("Session-Expires delta-seconds value is missing !");
            }
            try{
                m_Expires = Convert.ToInt32(word);
            }
            catch{
                throw new SIP_ParseException("Invalid Session-Expires delta-seconds value !");
            }

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

示例10: Parse

        /// <summary>
        /// Parses "Min-SE" 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)
        {
            /*
                Min-SE = delta-seconds *(SEMI generic-param)
            */

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

            // Parse address
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("Min-SE delta-seconds value is missing !");
            }
            try{
                m_Time = Convert.ToInt32(word);
            }
            catch{
                throw new SIP_ParseException("Invalid Min-SE delta-seconds value !");
            }

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

示例11: Parse

        /// <summary>
        /// Parses "reason-value" 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)
        {
            /*
                reason-value      =  protocol *(SEMI reason-params)
                protocol          =  "SIP" / "Q.850" / token
                reason-params     =  protocol-cause / reason-text / reason-extension
                protocol-cause    =  "cause" EQUAL cause
                cause             =  1*DIGIT
                reason-text       =  "text" EQUAL quoted-string
                reason-extension  =  generic-param
            */

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

            // protocol
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("SIP reason-value 'protocol' value is missing !");
            }
            m_Protocol = word;

            // Parse parameters
            ParseParameters(reader);
        }
开发者ID:dioptre,项目名称:nkd,代码行数:32,代码来源:SIP_t_ReasonValue.cs

示例12: Parse

        /// <summary>
        /// Parses "sec-mechanism" 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)
        {
            /*
                sec-mechanism    = mechanism-name *(SEMI mech-parameters)
                mechanism-name   = ( "digest" / "tls" / "ipsec-ike" / "ipsec-man" / token )
                mech-parameters  = ( preference / digest-algorithm / digest-qop / digest-verify / extension )
                preference       = "q" EQUAL qvalue
                qvalue           = ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] )
                digest-algorithm = "d-alg" EQUAL token
                digest-qop       = "d-qop" EQUAL token
                digest-verify    = "d-ver" EQUAL LDQUOT 32LHEX RDQUOT
                extension        = generic-param
            */

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

            // mechanism-name
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("Invalid 'sec-mechanism', 'mechanism-name' is missing !");
            }

            // Parse parameters
            ParseParameters(reader);
        }
开发者ID:dioptre,项目名称:nkd,代码行数:33,代码来源:SIP_t_SecMechanism.cs

示例13: Parse

        /// <summary>
        /// Parses "Retry-After" 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)
        {
            /*
                Retry-After = delta-seconds [ comment ] *( SEMI retry-param )
                retry-param = ("duration" EQUAL delta-seconds) / generic-param
            */

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

            // delta-seconds
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("SIP Retry-After 'delta-seconds' value is missing !");
            }
            try{
                m_Time = Convert.ToInt32(word);
            }
            catch{
                throw new SIP_ParseException("Invalid SIP Retry-After 'delta-seconds' value !");
            }

            // Parse parameters
            ParseParameters(reader);
        }
开发者ID:dioptre,项目名称:nkd,代码行数:32,代码来源:SIP_t_RetryAfter.cs

示例14: Parse

        /// <summary>
        /// Parses "Refer-Sub" 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)
        {
            /*
                Refer-Sub       = refer-sub-value *(SEMI exten)
                refer-sub-value = "true" / "false"
                exten           = generic-param        
            */

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

            // refer-sub-value
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("Refer-Sub refer-sub-value value is missing !");
            }
            try{
                m_Value = Convert.ToBoolean(word);
            }
            catch{
                throw new SIP_ParseException("Invalid Refer-Sub refer-sub-value value !");
            }

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

示例15: Parse

        /// <summary>
        /// Returns parsed IMAP SEARCH <b>UID (sequence set)</b> key.
        /// </summary>
        /// <param name="r">String reader.</param>
        /// <returns>Returns parsed IMAP SEARCH <b>UID (sequence set)</b> key.</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_Uid Parse(StringReader r)
        {
            if(r == null){
                throw new ArgumentNullException("r");
            }

            string word = r.ReadWord();
            if(!string.Equals(word,"UID",StringComparison.InvariantCultureIgnoreCase)){
                throw new ParseException("Parse error: Not a SEARCH 'UID' key.");
            }
            r.ReadToFirstChar();
            string value = r.QuotedReadToDelimiter(' ');
            if(value == null){
                throw new ParseException("Parse error: Invalid 'UID' value.");
            }
            IMAP_SequenceSet seqSet = new IMAP_SequenceSet();
            try{
                seqSet.Parse(value);
            }
            catch{
                throw new ParseException("Parse error: Invalid 'UID' value.");
            }

            return new IMAP_Search_Key_Uid(seqSet);
        }
开发者ID:andreikalatsei,项目名称:milskype,代码行数:32,代码来源:IMAP_Search_Key_Uid.cs


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