예제 #1
0
        // Returns Success
        public async Task <bool> DecompressAsync(Letter letter)
        {
            if (letter.LetterMetadata.Encrypted)
            {
                return(false);
            }                 // Don't decompress before decryption.

            if (letter.LetterMetadata.Compressed)
            {
                try
                {
                    letter.Body = await CompressionProvider.DecompressAsync(letter.Body).ConfigureAwait(false);

                    letter.LetterMetadata.Compressed = false;
                    letter.LetterMetadata.CustomFields[Constants.HeaderForCompressed] = false;

                    if (letter.LetterMetadata.CustomFields.ContainsKey(Constants.HeaderForCompression))
                    {
                        letter.LetterMetadata.CustomFields.Remove(Constants.HeaderForCompression);
                    }
                }
                catch { return(false); }
            }

            return(true);
        }
예제 #2
0
        // Returns Success
        public async Task <bool> DecompressAsync(IMessage message)
        {
            var metadata = message.GetMetadata();

            if (metadata.Encrypted)
            {
                return(false);
            }                 // Don't decompress before decryption.

            if (metadata.Compressed)
            {
                try
                {
                    message.Body        = (await CompressionProvider.DecompressAsync(message.Body).ConfigureAwait(false)).ToArray();
                    metadata.Compressed = false;
                    metadata.CustomFields[Constants.HeaderForCompressed] = false;

                    if (metadata.CustomFields.ContainsKey(Constants.HeaderForCompression))
                    {
                        metadata.CustomFields.Remove(Constants.HeaderForCompression);
                    }
                }
                catch { return(false); }
            }

            return(true);
        }