Exemplo n.º 1
0
        /// <summary>
        /// Compresses the specified text using the default compression method: Deflate
        /// </summary>
        public static byte[] CompressBytes(this byte[] bytes, string compressionType)
        {
            if (compressionType == CompressionTypes.Deflate)
            {
                return(DeflateProvider.Deflate(bytes));
            }

            if (compressionType == CompressionTypes.GZip)
            {
                return(GZipProvider.GZip(bytes));
            }

            throw new NotSupportedException(compressionType);
        }
Exemplo n.º 2
0
        public static Stream CompressStream(this Stream stream, string compressionType)
        {
            if (compressionType == CompressionTypes.Deflate)
            {
                return(DeflateProvider.DeflateStream(stream));
            }

            if (compressionType == CompressionTypes.GZip)
            {
                return(GZipProvider.GZipStream(stream));
            }

            throw new NotSupportedException(compressionType);
        }