public void FromLeftToRightType(TStorageItem left, TItem right) { List <IAttachment> list = new List <IAttachment>(); AttachmentCollection attachmentCollection = IrmUtils.GetAttachmentCollection(left); IList <AttachmentHandle> handles = attachmentCollection.GetHandles(); foreach (AttachmentHandle handle in handles) { using (Attachment attachment = attachmentCollection.Open(handle)) { IAttachment item = this.AttachmentConverter.Convert(attachment); list.Add(item); } } right.Attachments = list; }
public IEnumerable <IAttachment> GetAllAttachments() { using (IItem parentItem = this.BindToParentItem()) { AttachmentCollection attachmentCollection = IrmUtils.GetAttachmentCollection(parentItem); foreach (AttachmentHandle attachmentHandle in attachmentCollection.GetHandles()) { using (Attachment attachment = attachmentCollection.Open(attachmentHandle)) { StorageTranslator <IAttachment, IAttachment> translator = this.GetAttachmentTranslator(attachment.AttachmentType, false); IAttachment resultAttachment = translator.ConvertToEntity(attachment); yield return(resultAttachment); } } } yield break; }
// Token: 0x0600060B RID: 1547 RVA: 0x0002E8F8 File Offset: 0x0002CAF8 private bool CompareAttachments(AttachmentCollection originalAttachments, AttachmentCollection currentAttachments) { if (originalAttachments != null && currentAttachments != null) { if (originalAttachments.Count != currentAttachments.Count) { return(false); } IList <AttachmentHandle> handles = originalAttachments.GetHandles(); IList <AttachmentHandle> handles2 = currentAttachments.GetHandles(); for (int i = 0; i < handles.Count; i++) { using (Attachment originalAttachment = originalAttachments.Open(handles[i])) { using (Attachment currentAttachment = currentAttachments.Open(handles2[i])) { originalAttachment.Load(); currentAttachment.Load(); if (originalAttachment.AttachmentType != currentAttachment.AttachmentType) { return(false); } if (originalAttachment.DisplayName != currentAttachment.DisplayName) { return(false); } if (originalAttachment.FileExtension != currentAttachment.FileExtension) { return(false); } if (originalAttachment.FileName != currentAttachment.FileName) { return(false); } if (originalAttachment.Size != currentAttachment.Size) { return(false); } if (originalAttachment is StreamAttachmentBase && currentAttachment is StreamAttachmentBase) { if (!this.CompareStreams(() => ((StreamAttachmentBase)originalAttachment).TryGetContentStream(PropertyOpenMode.ReadOnly), () => ((StreamAttachmentBase)currentAttachment).TryGetContentStream(PropertyOpenMode.ReadOnly))) { return(false); } } else if (originalAttachment is ItemAttachment) { using (Item itemAsReadOnly = ((ItemAttachment)originalAttachment).GetItemAsReadOnly(HoldCleanupEnforcer.PropertyColumns)) { using (Item itemAsReadOnly2 = ((ItemAttachment)currentAttachment).GetItemAsReadOnly(HoldCleanupEnforcer.PropertyColumns)) { if (!this.AreItemsLegallyEqual(itemAsReadOnly.ClassName, itemAsReadOnly, itemAsReadOnly2)) { return(false); } } } } } } } } else if (originalAttachments != null || currentAttachments != null) { return(false); } return(true); }