Esempio n. 1
0
        private IAttachment CreateAttachment(IItem parentItem, IAttachment entity, AttachmentType attachmentType)
        {
            ItemIdAttachment     itemIdAttachment     = entity as ItemIdAttachment;
            AttachmentCollection attachmentCollection = this.GetAttachmentCollection(parentItem);
            IAttachment          attachment;
            StorageTranslator <IAttachment, IAttachment> storageTranslator;

            if (itemIdAttachment != null)
            {
                using (IItem item = this.BindToItem(base.IdConverter.ToStoreObjectId(itemIdAttachment.ItemToAttachId)))
                {
                    attachment        = attachmentCollection.AddExistingItem(item);
                    storageTranslator = AttachmentTranslator <ItemIdAttachment, ItemIdAttachmentSchema> .MetadataInstance;
                    goto IL_5E;
                }
            }
            attachment        = attachmentCollection.CreateIAttachment(attachmentType);
            storageTranslator = this.GetAttachmentTranslator(attachment.AttachmentType, false);
IL_5E:
            storageTranslator.SetPropertiesFromEntityOnStorageObject(entity, attachment);
            return(attachment);
        }