Beispiel #1
0
        private Stream AttachmentsStreamCallback(object context)
        {
            if (this.decryptedItem == null)
            {
                throw new StoragePermanentException(ServerStrings.FailedToAddAttachments);
            }
            this.SaveAndCloseCurrentAttachment();
            AttachmentType attachmentType  = (AttachmentType)context;
            AttachmentType attachmentType2 = attachmentType;
            AttachmentType attachmentType3;

            if (attachmentType2 != AttachmentType.OleObject)
            {
                if (attachmentType2 != AttachmentType.ByValue)
                {
                    if (attachmentType2 != AttachmentType.EmbeddedMessage)
                    {
                        throw new StoragePermanentException(ServerStrings.InvalidAttachmentType);
                    }
                    attachmentType3 = AttachmentType.EmbeddedMessage;
                }
                else
                {
                    attachmentType3 = AttachmentType.Stream;
                }
            }
            else
            {
                attachmentType3 = AttachmentType.Ole;
            }
            AttachmentCollection attachmentCollection = this.decryptedItem.AttachmentCollection;

            this.currentAttachment = attachmentCollection.Create(attachmentType3);
            ExTraceGlobals.RightsManagementTracer.TraceDebug <AttachmentType>((long)this.GetHashCode(), "Decrypting Attachment. AttachmentType {0}", attachmentType3);
            StreamAttachmentBase streamAttachmentBase = this.currentAttachment as StreamAttachmentBase;

            if (streamAttachmentBase != null)
            {
                return(streamAttachmentBase.GetContentStream(PropertyOpenMode.Create));
            }
            this.temporaryStreamForEmbeddedMessage = Streams.CreateTemporaryStorageStream();
            return(this.temporaryStreamForEmbeddedMessage);
        }
Beispiel #2
0
 protected static IAttachment CreateCopy(Attachment attachment, AttachmentCollection collection, AttachmentType?newAttachmentType)
 {
     return(collection.Create(newAttachmentType, attachment));
 }