Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MailKit.Net.Imap.ImapLiteral"/> class.
        /// </summary>
        /// <remarks>
        /// Creates a new <see cref="MailKit.Net.Imap.ImapLiteral"/>.
        /// </remarks>
        /// <param name="options">The formatting options.</param>
        /// <param name="literal">The literal.</param>
        public ImapLiteral(FormatOptions options, object literal)
        {
            format = options;

            if (literal is MimeMessage)
            {
                Type = ImapLiteralType.MimeMessage;
            }
            else if (literal is Stream)
            {
                Type = ImapLiteralType.Stream;
            }
            else if (literal is string)
            {
                literal = Encoding.UTF8.GetBytes((string)literal);
                Type    = ImapLiteralType.String;
            }
            else if (literal is byte[])
            {
                Type = ImapLiteralType.String;
            }
            else
            {
                throw new ArgumentException("Unknown literal type");
            }

            Literal = literal;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MailKit.Net.Imap.ImapLiteral"/> class.
        /// </summary>
        /// <remarks>
        /// Creates a new <see cref="MailKit.Net.Imap.ImapLiteral"/>.
        /// </remarks>
        /// <param name="options">The formatting options.</param>
        /// <param name="literal">The literal.</param>
        /// <param name="action">The progress update action.</param>
        public ImapLiteral(FormatOptions options, object literal, Action <int> action = null)
        {
            format = options.Clone();
            format.NewLineFormat = NewLineFormat.Dos;

            update = action;

            if (literal is MimeMessage)
            {
                Type = ImapLiteralType.MimeMessage;
            }
            else if (literal is Stream)
            {
                Type = ImapLiteralType.Stream;
            }
            else if (literal is string)
            {
                literal = Encoding.UTF8.GetBytes((string)literal);
                Type    = ImapLiteralType.String;
            }
            else if (literal is byte[])
            {
                Type = ImapLiteralType.String;
            }
            else
            {
                throw new ArgumentException("Unknown literal type");
            }

            Literal = literal;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MailKit.Net.Imap.ImapLiteral"/> class.
        /// </summary>
        /// <remarks>
        /// Creates a new <see cref="MailKit.Net.Imap.ImapLiteral"/>.
        /// </remarks>
        /// <param name="options">The formatting options.</param>
        /// <param name="literal">The literal.</param>
        public ImapLiteral(FormatOptions options, byte[] literal)
        {
            format = options.Clone();
            format.NewLineFormat = NewLineFormat.Dos;

            Type    = ImapLiteralType.String;
            Literal = literal;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MailKit.Net.Imap.ImapLiteral"/> class.
        /// </summary>
        /// <remarks>
        /// Creates a new <see cref="MailKit.Net.Imap.ImapLiteral"/>.
        /// </remarks>
        /// <param name="options">The formatting options.</param>
        /// <param name="literal">The literal.</param>
        /// <param name="action">The progress update action.</param>
        public ImapLiteral(FormatOptions options, MimeMessage literal, Action <int> action = null)
        {
            format = options.Clone();
            format.NewLineFormat = NewLineFormat.Dos;

            update = action;

            Type    = ImapLiteralType.MimeMessage;
            Literal = literal;
        }
Exemplo n.º 5
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MailKit.Net.Imap.ImapLiteral"/> class.
		/// </summary>
		/// <remarks>
		/// Creates a new <see cref="MailKit.Net.Imap.ImapLiteral"/>.
		/// </remarks>
		/// <param name="options">The formatting options.</param>
		/// <param name="literal">The literal.</param>
		/// <param name="action">The progress update action.</param>
		public ImapLiteral (FormatOptions options, object literal, Action<int> action = null)
		{
			format = options.Clone ();
			format.NewLineFormat = NewLineFormat.Dos;

			update = action;

			if (literal is MimeMessage) {
				Type = ImapLiteralType.MimeMessage;
			} else if (literal is Stream) {
				Type = ImapLiteralType.Stream;
			} else if (literal is string) {
				literal = Encoding.UTF8.GetBytes ((string) literal);
				Type = ImapLiteralType.String;
			} else if (literal is byte[]) {
				Type = ImapLiteralType.String;
			} else {
				throw new ArgumentException ("Unknown literal type");
			}

			Literal = literal;
		}
Exemplo n.º 6
0
		public ImapLiteral (object literal)
		{
			if (literal is MimeMessage) {
				Type = ImapLiteralType.MimeMessage;
			} else if (literal is Stream) {
				Type = ImapLiteralType.Stream;
			} else if (literal is string) {
				literal = Encoding.UTF8.GetBytes ((string) literal);
				Type = ImapLiteralType.String;
			} else if (literal is byte[]) {
				Type = ImapLiteralType.String;
			} else {
				throw new ArgumentException ("Unknown literal type");
			}

			Literal = literal;
		}