https://github.com/shuttle/shuttle.core.compression
Compression adapter.
https://github.com/shuttle/shuttle.core.compression
Last synced: 9 months ago
JSON representation
Compression adapter.
- Host: GitHub
- URL: https://github.com/shuttle/shuttle.core.compression
- Owner: Shuttle
- License: bsd-3-clause
- Created: 2018-01-02T08:07:57.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-02T11:18:20.000Z (11 months ago)
- Last Synced: 2025-04-08T23:13:48.878Z (9 months ago)
- Language: C#
- Size: 98.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shuttle.Core.Compression
```
PM> Install-Package Shuttle.Core.Compression
```
Provides a compression adapter through the `ICompressionAlgorithm` interface.
Implementations available in this package:
- `DeflateCompressionAlgorithm`
- `GZipCompressionAlgorithm`
- `NullCompressionAlgorithm`
There is also an `ICompressionService` that acts as a central container for all registered `ICompressionAlgorithm` implementations.
## Configuration
In order to add compression:
```c#
services.AddCompression();
```
This will try to add the `CompressionService` singleton.
In order to add specific compression algorithms use the relevant builder calls:
```c#
services.AddCompression(builder => {
builder.AddGzip();
builder.AddDeflate();
builder.AddNull();
});
```
## Usage
The `ICompressionService` can be injected into any class that requires compression services:
```c#
var algorithm = compressionService.Get("algorithm-name");
var compressed = await algorithm.CompressAsync(Encoding.UTF8.GetBytes("some data"));
var decompressed = await algorithm.DecompressAsync(compressed);
```