Ejemplo n.º 1
0
		/// <summary>
		/// Parses the body structure of a mail message as is returned by the IMAP server
		/// in response to a FETCH BODYSTRUCTURE command.
		/// </summary>
		/// <param name="text">The body structure server response</param>
		/// <returns>An array of initialized Bodypart objects representing the body
		/// structure of the mail message</returns>
		/// <exception cref="FormatException">Thrown if the passed string does not
		/// contain a valid body structure and parsing failed.</exception>
		public static Bodypart[] Parse(string text) {
			Bodystructure s = new Bodystructure(text);
			List<Bodypart> list = new List<Bodypart>();
			try {
				char c = (char)s.reader.Peek();
				if (c == '(')
					list.AddRange(s.ParseList());
				else
					list.Add(s.ParseBodypart("1", false));
			} catch (Exception) {
				throw new FormatException(text);
			}
			return list.ToArray();
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the body structure of a mail message as is returned by the IMAP server
        /// in response to a FETCH BODYSTRUCTURE command.
        /// </summary>
        /// <param name="text">The body structure server response</param>
        /// <returns>An array of initialized Bodypart objects representing the body
        /// structure of the mail message</returns>
        /// <exception cref="FormatException">Thrown if the passed string does not
        /// contain a valid body structure and parsing failed.</exception>
        public static Bodypart[] Parse(string text)
        {
            Bodystructure   s    = new Bodystructure(text);
            List <Bodypart> list = new List <Bodypart>();

            try {
                char c = (char)s.reader.Peek();
                if (c == '(')
                {
                    list.AddRange(s.ParseList());
                }
                else
                {
                    list.Add(s.ParseBodypart("1", false));
                }
            } catch (Exception) {
                throw new FormatException(text);
            }
            return(list.ToArray());
        }