예제 #1
0
        /// <summary>
        /// Recovers the attachment information from serializable attachment data.
        /// </summary>
        /// <param name="data">The attachment data.</param>
        /// <returns>The attachment.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="data"/> is null.</exception>
        public static Attachment FromAttachmentData(AttachmentData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            return((data.Type == AttachmentType.Text)
                ? (Attachment) new TextAttachment(data.Name, data.ContentType, data.GetText())
                : (Attachment) new BinaryAttachment(data.Name, data.ContentType, data.GetBytes()));
        }