BinaryProcess 1.0.5
dotnet add package BinaryProcess --version 1.0.5
NuGet\Install-Package BinaryProcess -Version 1.0.5
<PackageReference Include="BinaryProcess" Version="1.0.5" />
<PackageVersion Include="BinaryProcess" Version="1.0.5" />
<PackageReference Include="BinaryProcess" />
paket add BinaryProcess --version 1.0.5
#r "nuget: BinaryProcess, 1.0.5"
#:package BinaryProcess@1.0.5
#addin nuget:?package=BinaryProcess&version=1.0.5
#tool nuget:?package=BinaryProcess&version=1.0.5
BinaryProcess
处理数组和字节之间的转换,压缩字节减少体积,保存到本地,读取和保存速度极快,目前支持int,short,float,long,uint,ushort,ulong,double,decimal 类型的数组。
准确判断文件类型,不是简单的通过后缀判断,支持的类型:zip,gz,tgz,rar,pdf,wav,avi,mpeg,cad,bmp,jpg,png,gif,tiff。
Handle the conversion between arrays and bytes, compress bytes to reduce volume, save to local, with extremely fast reading and saving speed. Currently supports arrays of types int, short, float, long, uint, ushort, ulong, double, and decimal.
Accurately determine the file type, not simply by the suffix. Supported types: zip, gz, tgz, rar, pdf, wav, avi, mpeg, cad, bmp, jpg, png, gif, tiff.
安装
dotnet add package BinaryProcess
代码使用示例
// 准备测试数据
int[,] int_array = { { 1, 2, 3 }, { 4, 5, 6 } };
short[,] short_array = { { 1, 2, 3 }, { 4, 5, 6 } };
float[,] float_array = { { 1.1f, 2.2f, 3.3f }, { 4.4f, 5.5f, 6.6f } };
long[,] long_array = { { 1L, 2L, 3L }, { 4L, 5L, 6L } };
uint[,] uint_array = { { 1u, 2u, 3u }, { 4u, 5u, 6u } };
ushort[,] ushort_array = { { 1, 2, 3 }, { 4, 5, 6 } };
ulong[,] ulong_array = { { 1ul, 2ul, 3ul }, { 4ul, 5ul, 6ul } };
double[,] double_array = { { 1.1, 2.2, 3.3 }, { 4.4, 5.5, 6.6 } };
decimal[,] decimal_array = { { 1.1m, 2.2m, 3.3m }, { 4.4m, 5.5m, 6.6m } };
// 测试int数组转换
byte[] int_bytes = BinaryArray.ToByte(int_array);
int[,] int_array_result = BinaryArray.ToArray<int[,]>(int_bytes);
// 测试short数组转换
byte[] short_bytes = BinaryArray.ToByte(short_array);
short[,] short_array_result = BinaryArray.ToArray<short[,]>(short_bytes);
// 测试float数组转换
byte[] float_bytes = BinaryArray.ToByte(float_array);
float[,] float_array_result = BinaryArray.ToArray<float[,]>(float_bytes);
// 测试long数组转换
byte[] long_bytes = BinaryArray.ToByte(long_array);
long[,] long_array_result = BinaryArray.ToArray<long[,]>(long_bytes);
// 测试uint数组转换
byte[] uint_bytes = BinaryArray.ToByte(uint_array);
uint[,] uint_array_result = BinaryArray.ToArray<uint[,]>(uint_bytes);
// 测试ushort数组转换
byte[] ushort_bytes = BinaryArray.ToByte(ushort_array);
ushort[,] ushort_array_result = BinaryArray.ToArray<ushort[,]>(ushort_bytes);
// 测试ulong数组转换
byte[] ulong_bytes = BinaryArray.ToByte(ulong_array);
ulong[,] ulong_array_result = BinaryArray.ToArray<ulong[,]>(ulong_bytes);
// 测试double数组转换
byte[] double_bytes = BinaryArray.ToByte(double_array);
double[,] double_array_result = BinaryArray.ToArray<double[,]>(double_bytes);
// 测试decimal数组转换
byte[] decimal_bytes = BinaryArray.ToByte(decimal_array);
decimal[,] decimal_array_result = BinaryArray.ToArray<decimal[,]>(decimal_bytes);
Dictionary<string, FileType> dict = new Dictionary<string, FileType>();
dict.Add("D:\\files\\A.bmp", FileType.BMP);
dict.Add("D:\\files\\A.jpg", FileType.JPG);
dict.Add("D:\\files\\A.png", FileType.PNG);
dict.Add("D:\\files\\A.gif", FileType.GIF);
dict.Add("D:\\files\\A.tif", FileType.TIFF);
foreach (KeyValuePair<string, FileType> kvp in dict)
{
bool flag = BinaryFile.Verify(kvp.Key, kvp.Value);
Debug.WriteLine($"【{kvp.Key}】 测试结果 【{flag}】");
}
文件类型判断
主要通过***BinaryFile.Verify()***方法实现
版本更新
1.0.0
- 基础版只有数组转字节功能
1.0.1
- 增加使用魔数判断文件类型功能
1.0.3
- 大幅度提高转换速度
- 转换函数增加是否压缩字节参数
1.0.4
- 修复Read 泛型传参bug
1.0.5
- 修复ToArray 缺少reduce参数
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net5.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.