Example #1
0
        /// <summary>
        /// Parses IMAP optional response from reader.
        /// </summary>
        /// <param name="r">Optional response reader.</param>
        /// <returns>Returns parsed optional response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
        public static IMAP_t_orc Parse(StringReader r)
        {
            if (r == null)
            {
                throw new ArgumentNullException("r");
            }

            r.ReadToFirstChar();

            if (r.StartsWith("[ALERT", false))
            {
                return(IMAP_t_orc_Alert.Parse(r));
            }
            else if (r.StartsWith("[BADCHARSET", false))
            {
                return(IMAP_t_orc_BadCharset.Parse(r));
            }
            else if (r.StartsWith("[CAPABILITY", false))
            {
                return(IMAP_t_orc_Capability.Parse(r));
            }
            else if (r.StartsWith("[PARSE", false))
            {
                return(IMAP_t_orc_Parse.Parse(r));
            }
            else if (r.StartsWith("[PERMANENTFLAGS", false))
            {
                return(IMAP_t_orc_PermanentFlags.Parse(r));
            }
            else if (r.StartsWith("[READ-ONLY", false))
            {
                return(IMAP_t_orc_ReadOnly.Parse(r));
            }
            else if (r.StartsWith("[READ-WRITE", false))
            {
                return(IMAP_t_orc_ReadWrite.Parse(r));
            }
            else if (r.StartsWith("[TRYCREATE", false))
            {
                return(IMAP_t_orc_TryCreate.Parse(r));
            }
            else if (r.StartsWith("[UIDNEXT", false))
            {
                return(IMAP_t_orc_UidNext.Parse(r));
            }
            else if (r.StartsWith("[UIDVALIDITY", false))
            {
                return(IMAP_t_orc_UidValidity.Parse(r));
            }
            else if (r.StartsWith("[UNSEEN", false))
            {
                return(IMAP_t_orc_Unseen.Parse(r));
            }
            //---------------------
            else if (r.StartsWith("[APPENDUID", false))
            {
                return(IMAP_t_orc_AppendUid.Parse(r));
            }
            else if (r.StartsWith("[COPYUID", false))
            {
                return(IMAP_t_orc_CopyUid.Parse(r));
            }
            else
            {
                return(IMAP_t_orc_Unknown.Parse(r));
            }
        }
Example #2
0
        /// <summary>
        /// Parses IMAP optional response from string.
        /// </summary>
        /// <param name="value">Optional response string.</param>
        /// <returns>Returns parsed optional response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>value</b> is null reference.</exception>
        public static IMAP_t_orc Parse(string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            string responseCode = value.Split(' ')[0];

            if (string.Equals("ALERT", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_Alert.Parse(value));
            }
            else if (string.Equals("BADCHARSET", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_BadCharset.Parse(value));
            }
            else if (string.Equals("CAPABILITY", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_Capability.Parse(value));
            }
            else if (string.Equals("PARSE", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_Parse.Parse(value));
            }
            else if (string.Equals("PERMANENTFLAGS", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_PermanentFlags.Parse(value));
            }
            else if (string.Equals("READ-ONLY", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_ReadOnly.Parse(value));
            }
            else if (string.Equals("READ-WRITE", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_ReadWrite.Parse(value));
            }
            else if (string.Equals("TRYCREATE", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_TryCreate.Parse(value));
            }
            else if (string.Equals("UIDNEXT", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_UidNext.Parse(value));
            }
            else if (string.Equals("UIDVALIDITY", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_UidValidity.Parse(value));
            }
            else if (string.Equals("UNSEEN", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_Unseen.Parse(value));
            }
            //---------------------
            else if (string.Equals("APPENDUID", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_AppendUid.Parse(value));
            }
            else if (string.Equals("COPYUID", responseCode, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IMAP_t_orc_CopyUid.Parse(value));
            }
            else
            {
                return(IMAP_t_orc_Unknown.Parse(value));
            }
        }