Beispiel #1
0
        internal static ReadOnlyCollection <AttachmentLink> MergeAttachmentLinks(IList <AttachmentLink> existingLinks, CoreAttachmentCollection attachments)
        {
            IList <AttachmentLink> list;

            if (attachments != null)
            {
                list = ((existingLinks == null) ? new List <AttachmentLink>(attachments.Count) : new List <AttachmentLink>(existingLinks));
                ICollection <PropertyDefinition> preloadProperties = new PropertyDefinition[]
                {
                    AttachmentSchema.AttachContentId
                };
                using (IEnumerator <AttachmentHandle> enumerator = attachments.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AttachmentHandle handle = enumerator.Current;
                        using (CoreAttachment coreAttachment = attachments.Open(handle, preloadProperties))
                        {
                            using (Attachment attachment = AttachmentCollection.CreateTypedAttachment(coreAttachment, null))
                            {
                                if (AttachmentLink.Find(attachment.Id, list) == null)
                                {
                                    AttachmentLink item = new AttachmentLink(attachment);
                                    list.Add(item);
                                }
                            }
                        }
                    }
                    goto IL_C5;
                }
            }
            list = ((existingLinks == null) ? new List <AttachmentLink>(0) : new List <AttachmentLink>(existingLinks));
IL_C5:
            return(new ReadOnlyCollection <AttachmentLink>(list));
        }
        protected void CopyAttachments(BodyConversionCallbacks callbacks, AttachmentCollection sourceCollection, AttachmentCollection targetCollection, bool copyInlinesOnly, bool targetIsPlainText, InboundConversionOptions optionsForSmime)
        {
            ReadOnlyCollection <AttachmentLink> readOnlyCollection = null;
            bool flag = true;

            if (callbacks.HtmlCallback != null && callbacks.HtmlCallback.AttachmentListInitialized)
            {
                readOnlyCollection = callbacks.HtmlCallback.AttachmentLinks;
                flag = (flag && callbacks.HtmlCallback.ClearInlineOnUnmarkedAttachments);
            }
            if (callbacks.RtfCallback != null && callbacks.RtfCallback.AttachmentListInitialized)
            {
                readOnlyCollection = callbacks.RtfCallback.AttachmentLinks;
                flag = (flag && callbacks.RtfCallback.ClearInlineOnUnmarkedAttachments);
            }
            if (readOnlyCollection == null)
            {
                if (copyInlinesOnly)
                {
                    return;
                }
                using (IEnumerator <AttachmentHandle> enumerator = sourceCollection.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AttachmentHandle handle = enumerator.Current;
                        using (Attachment attachment = sourceCollection.Open(handle, null))
                        {
                            if (!attachment.IsCalendarException)
                            {
                                using (Attachment attachment2 = attachment.CreateCopy(targetCollection, new BodyFormat?(this.parameters.TargetFormat)))
                                {
                                    attachment2.IsInline = false;
                                    attachment2.Save();
                                }
                            }
                        }
                    }
                    return;
                }
            }
            foreach (AttachmentLink attachmentLink in readOnlyCollection)
            {
                if (!copyInlinesOnly || attachmentLink.IsInline(flag))
                {
                    using (Attachment attachment3 = sourceCollection.Open(attachmentLink.AttachmentId, null))
                    {
                        if (!copyInlinesOnly || !(attachment3 is ReferenceAttachment))
                        {
                            using (Attachment attachment4 = attachment3.CreateCopy(targetCollection, new BodyFormat?(this.parameters.TargetFormat)))
                            {
                                attachmentLink.MakeAttachmentChanges(attachment4, flag);
                                if (targetIsPlainText)
                                {
                                    attachment4.IsInline = false;
                                }
                                attachment4.Save();
                            }
                        }
                    }
                }
            }
        }
 internal ExceptionSummary(AttachmentHandle handle, ExDateTime utcStart, ExDateTime utcEnd)
 {
     this.Handle       = handle;
     this.UtcStartTime = utcStart;
     this.UtcEndTime   = utcEnd;
 }