PM> Install-Package Shuttle.Core.Compression
Provides a compression adapter through the ICompressionAlgorithm interface.
Implementations available in this package:
DeflateCompressionAlgorithmGZipCompressionAlgorithmNullCompressionAlgorithm
There is also an ICompressionService that acts as a central container for all registered ICompressionAlgorithm implementations.
In order to add compression:
services.AddCompression();This will try to add the CompressionService singleton.
In order to add specific compression algorithms use the relevant builder calls:
services.AddCompression(builder => {
builder.AddGzip();
builder.AddDeflate();
builder.AddNull();
});The ICompressionService can be injected into any class that requires compression services:
var algorithm = compressionService.Get("algorithm-name");
var compressed = await algorithm.CompressAsync(Encoding.UTF8.GetBytes("some data"));
var decompressed = await algorithm.DecompressAsync(compressed);