144 lines
3.8 KiB
Markdown
144 lines
3.8 KiB
Markdown
# <a id="CapyKit_Helpers_CompressionHelper"></a> Class CompressionHelper
|
|
|
|
Namespace: [CapyKit.Helpers](CapyKit.Helpers.md)
|
|
Assembly: CapyKit.dll
|
|
|
|
A class that contains methods for managing data compression.
|
|
|
|
```csharp
|
|
public static class CompressionHelper
|
|
```
|
|
|
|
#### Inheritance
|
|
|
|
[object](https://learn.microsoft.com/dotnet/api/system.object) ←
|
|
[CompressionHelper](CapyKit.Helpers.CompressionHelper.md)
|
|
|
|
#### Inherited Members
|
|
|
|
[object.Equals\(object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\)),
|
|
[object.Equals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\-system\-object\)),
|
|
[object.GetHashCode\(\)](https://learn.microsoft.com/dotnet/api/system.object.gethashcode),
|
|
[object.GetType\(\)](https://learn.microsoft.com/dotnet/api/system.object.gettype),
|
|
[object.MemberwiseClone\(\)](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone),
|
|
[object.ReferenceEquals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals),
|
|
[object.ToString\(\)](https://learn.microsoft.com/dotnet/api/system.object.tostring)
|
|
|
|
#### Extension Methods
|
|
|
|
[ObjectExtensions.UpdateProperties\(object, object\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_System\_Object\_System\_Object\_)
|
|
|
|
## Methods
|
|
|
|
### <a id="CapyKit_Helpers_CompressionHelper_Compress_System_Object_"></a> Compress\(object\)
|
|
|
|
Compresses a given object using the <code>gzip</code> algorithm.
|
|
|
|
```csharp
|
|
public static byte[] Compress(object obj)
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
`obj` [object](https://learn.microsoft.com/dotnet/api/system.object)
|
|
|
|
The object.
|
|
|
|
#### Returns
|
|
|
|
[byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]
|
|
|
|
A byte array representing the compressed object in <code>gzip</code> format.
|
|
|
|
### <a id="CapyKit_Helpers_CompressionHelper_CompressToString_System_Object_"></a> CompressToString\(object\)
|
|
|
|
Compresses a given object to a string using <code>base64</code> encoding of <code>gzip</code> format.
|
|
|
|
```csharp
|
|
public static string CompressToString(object obj)
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
`obj` [object](https://learn.microsoft.com/dotnet/api/system.object)
|
|
|
|
The object.
|
|
|
|
#### Returns
|
|
|
|
[string](https://learn.microsoft.com/dotnet/api/system.string)
|
|
|
|
A string in <code>base64</code> encoding.
|
|
|
|
### <a id="CapyKit_Helpers_CompressionHelper_Decompress__1_System_String_"></a> Decompress<T\>\(string\)
|
|
|
|
Decompresses a given <code>base64</code> encoded string of <code>gzip</code> format.
|
|
|
|
```csharp
|
|
public static T Decompress<T>(string encodedString)
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
`encodedString` [string](https://learn.microsoft.com/dotnet/api/system.string)
|
|
|
|
The <code>base64</code> encoded <code>gzip</code> string.
|
|
|
|
#### Returns
|
|
|
|
T
|
|
|
|
A <code class="typeparamref">T</code> typed object.
|
|
|
|
#### Type Parameters
|
|
|
|
`T`
|
|
|
|
Generic type parameter.
|
|
|
|
### <a id="CapyKit_Helpers_CompressionHelper_Decompress__1_System_Byte___"></a> Decompress<T\>\(byte\[\]\)
|
|
|
|
Decompresses a given compressed <code>gzip</code> byte stream.
|
|
|
|
```csharp
|
|
public static T Decompress<T>(byte[] byteStream)
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
`byteStream` [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]
|
|
|
|
The compressed byte stream.
|
|
|
|
#### Returns
|
|
|
|
T
|
|
|
|
A <code class="typeparamref">T</code> typed object.
|
|
|
|
#### Type Parameters
|
|
|
|
`T`
|
|
|
|
Generic type parameter.
|
|
|
|
### <a id="CapyKit_Helpers_CompressionHelper_DecompressToString_System_String_"></a> DecompressToString\(string\)
|
|
|
|
Decompresses the given <code>base64</code> string in <code>gzip</code> format.
|
|
|
|
```csharp
|
|
public static string DecompressToString(string compressed)
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
`compressed` [string](https://learn.microsoft.com/dotnet/api/system.string)
|
|
|
|
The compressed string.
|
|
|
|
#### Returns
|
|
|
|
[string](https://learn.microsoft.com/dotnet/api/system.string)
|
|
|
|
A decomressed string.
|
|
|