Пример #1
0
        public Message DecompressMessage(Message sourceMessage)
        {
            if (!sourceMessage.IsCompressed())
            {
                return(sourceMessage);
            }
            CompressionAlgorithm algorithm = sourceMessage.GetCompressionAlgorithm();

            sourceMessage.RemoveCompressionHeader();
            byte[] compressedBody   = sourceMessage.GetCompressedBody();
            byte[] decompressedBody = DataCompressor.Decompress(compressedBody, algorithm);
            string newMessageXml    = Encoding.UTF8.GetString(decompressedBody);

            XmlTextReader reader = new XmlTextReader(new StringReader(newMessageXml));
            Message       decompressedMessage = Message.CreateMessage(sourceMessage.Version, null, reader);

            decompressedMessage.Headers.CopyHeadersFrom(sourceMessage);
            decompressedMessage.Properties.CopyProperties(sourceMessage.Properties);
            return(decompressedMessage);
        }