コード例 #1
0
 public Stream GetReadOnlyApplefileStream()
 {
     base.CheckDisposed("GetReadOnlyApplefileStream");
     if (this.IsFlaggedAsMacAttachment)
     {
         object obj = base.TryGetProperty(InternalSchema.AttachmentMacInfo);
         if (obj is byte[])
         {
             return(new MemoryStream(obj as byte[], false));
         }
         if (PropertyError.IsPropertyValueTooBig(obj))
         {
             return(this.OpenPropertyStream(InternalSchema.AttachmentMacInfo, PropertyOpenMode.ReadOnly));
         }
         using (Stream rawContentStream = this.GetRawContentStream(PropertyOpenMode.ReadOnly))
         {
             if (this.IsMacAttachmentInternal(rawContentStream))
             {
                 using (DisposeGuard disposeGuard = default(DisposeGuard))
                 {
                     Stream stream = disposeGuard.Add <MemoryStream>(new MemoryStream());
                     string text   = null;
                     byte[] array  = null;
                     MimeAppleTranscoder.MacBinToApplefile(rawContentStream, stream, out text, out array);
                     disposeGuard.Success();
                     return(stream);
                 }
             }
             throw new CorruptDataException(ServerStrings.ConversionFailedInvalidMacBin);
         }
     }
     throw new InvalidOperationException();
 }
コード例 #2
0
 private bool IsMacAttachmentInternal(Stream attachStream)
 {
     this.isMacAttachment = new bool?(false);
     if (this.IsFlaggedAsMacAttachment && attachStream != null)
     {
         this.isMacAttachment = new bool?(MimeAppleTranscoder.IsMacBinStream(attachStream));
     }
     return(this.isMacAttachment.Value);
 }
コード例 #3
0
        public override Stream GetContentStream(PropertyOpenMode openMode)
        {
            base.CheckDisposed("GetContentStream");
            Stream contentStream = base.GetContentStream(openMode);

            if (!this.IsMacAttachmentInternal(contentStream))
            {
                return(contentStream);
            }
            if (openMode == PropertyOpenMode.ReadOnly)
            {
                return(MimeAppleTranscoder.ExtractDataFork(contentStream));
            }
            throw new InvalidOperationException("Unable to get write stream for mac attachment.");
        }