예제 #1
0
		/// <summary>
		/// Initializes a new instance of the Bodypart class with default
		/// values.
		/// </summary>
		/// <param name="partNumber">The part number as is expected by the
		/// IMAP FETCH command.</param>
		internal Bodypart(string partNumber) {
			// Initialize all fields with default values.
			PartNumber = partNumber;
			Type = ContentType.Other;
			Subtype = Id = Description = Md5 = Language = Location = "";
			Parameters = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
			Disposition = new ContentDisposition();
			Encoding = ContentTransferEncoding.Unknown;
			Size = Lines = 0;
		}
예제 #2
0
파일: Reader.cs 프로젝트: abhibecb/S22.Imap
		/// <summary>
		/// Reads a disposition from the underlying string. A disposition in
		/// this context is a list of attribute/value literals (enclosed in
		/// double-quotes) preceded by a word enclosed in parenthesis.
		/// </summary>
		/// <returns>An initialized ContentDisposition instance representing
		/// the parsed disposition.</returns>
		/// <exception cref="EndOfStringException">Thrown when reading is
		/// attempted past the end of the underlying string.</exception>
		public ContentDisposition ReadDisposition() {
			ContentDisposition Disp = new ContentDisposition();
			char c;
			char[] last = new char[3];
			while ((c = (char)Read()) != '(') {
				last[0] = last[1];
				last[1] = last[2];
				last[2] = c;
				if ((new string(last)) == "NIL")
					return Disp;
			}

			string type = ReadWord();
			Disp.Type = ContentDispositionTypeMap.fromString(type);
			Disp.Attributes = ReadList();
			ReadUntil(')');

			if (Disp.Attributes.ContainsKey("Filename"))
				Disp.Filename = Disp.Attributes["Filename"];
			return Disp;
		}