internal static SerializeableAlternateView GetSerializeableAlternateView(AlternateView av)
        {
            if (av == null)
            {
                return(null);
            }

            var sav = new SerializeableAlternateView();

            sav._baseUri   = av.BaseUri;
            sav._contentId = av.ContentId;

            if (av.ContentStream != null)
            {
                var bytes = new byte[av.ContentStream.Length];
                av.ContentStream.Read(bytes, 0, bytes.Length);
                sav._contentStream = new MemoryStream(bytes);
            }

            sav._contentType = SerializeableContentType.GetSerializeableContentType(av.ContentType);

            foreach (LinkedResource lr in av.LinkedResources)
            {
                sav._linkedResources.Add(SerializeableLinkedResource.GetSerializeableLinkedResource(lr));
            }

            sav._transferEncoding = av.TransferEncoding;
            return(sav);
        }
예제 #2
0
        ///
        /// Creates a new serializeable mailmessage based on a MailMessage object
        ///
        public SerializeableMailMessage(MailMessage mailMessage)
        {
            IsBodyHtml = mailMessage.IsBodyHtml;
            Body       = mailMessage.Body;
            Subject    = mailMessage.Subject;
            From       = SerializeableMailAddress.GetSerializeableMailAddress(mailMessage.From);
            _to        = new List <SerializeableMailAddress>();
            foreach (var mailAddress in mailMessage.To)
            {
                _to.Add(SerializeableMailAddress.GetSerializeableMailAddress(mailAddress));
            }

            _cc = new List <SerializeableMailAddress>();
            foreach (var mailAddress in mailMessage.CC)
            {
                _cc.Add(SerializeableMailAddress.GetSerializeableMailAddress(mailAddress));
            }

            _bcc = new List <SerializeableMailAddress>();
            foreach (var mailAddress in mailMessage.Bcc)
            {
                _bcc.Add(SerializeableMailAddress.GetSerializeableMailAddress(mailAddress));
            }

            _attachments = new List <SerializeableAttachment>();
            foreach (var attachment in mailMessage.Attachments)
            {
                _attachments.Add(SerializeableAttachment.GetSerializeableAttachment(attachment));
            }

            _bodyEncoding = mailMessage.BodyEncoding;

            _deliveryNotificationOptions = mailMessage.DeliveryNotificationOptions;
            _headers         = SerializeableCollection.GetSerializeableCollection(mailMessage.Headers);
            _priority        = mailMessage.Priority;
            ReplyTo          = mailMessage.ReplyToList.Select(SerializeableMailAddress.GetSerializeableMailAddress).ToList();
            Sender           = SerializeableMailAddress.GetSerializeableMailAddress(mailMessage.Sender);
            _subjectEncoding = mailMessage.SubjectEncoding;

            foreach (AlternateView av in mailMessage.AlternateViews)
            {
                _alternateViews.Add(SerializeableAlternateView.GetSerializeableAlternateView(av));
            }
        }