示例#1
0
        /// <summary>
        /// Returns serializable attachment
        /// </summary>
        /// <param name="att"></param>
        /// <returns></returns>
        public static SerializableAttachment GetSerializeableAttachment(Attachment att)
        {
            if (att == null)
            {
                return(null);
            }

            var serializedAttachment = new SerializableAttachment
            {
                serializedContentDisposition = SerializableContentDisposition.GetSerializableContentDisposition(att.ContentDisposition),
                contentId = att.ContentId
            };

            if (att.ContentStream != null)
            {
                var bytes = new byte[att.ContentStream.Length];
                att.ContentStream.Read(bytes, 0, bytes.Length);

                serializedAttachment.serializedContentStream = new MemoryStream(bytes);
            }

            serializedAttachment.name = att.Name;
            serializedAttachment.serializedContentType = SerializableContentType.GetSerializableContentType(att.ContentType);
            serializedAttachment.nameEncoding          = att.NameEncoding;
            serializedAttachment.transferEncoding      = att.TransferEncoding;
            return(serializedAttachment);
        }
示例#2
0
        /// <summary>
        /// Serailizes ontent disposition
        /// </summary>
        /// <param name="contentDisposition">content disposition to be serialized</param>
        /// <returns>serialized content disposition</returns>
        public static SerializableContentDisposition GetSerializableContentDisposition(ContentDisposition contentDisposition)
        {
            if (contentDisposition == null)
            {
                return(null);
            }

            var serializedContentDisposition = new SerializableContentDisposition
            {
                creationDate            = contentDisposition.CreationDate,
                dispositionType         = contentDisposition.DispositionType,
                fileName                = contentDisposition.FileName,
                inline                  = contentDisposition.Inline,
                modificationDate        = contentDisposition.ModificationDate,
                serializedColParameters = SerializableCollection.GetSerializableCollection(contentDisposition.Parameters),
                readDate                = contentDisposition.ReadDate,
                size = contentDisposition.Size
            };

            return(serializedContentDisposition);
        }