Xunet 1.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package Xunet --version 1.0.6                
NuGet\Install-Package Xunet -Version 1.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xunet" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xunet --version 1.0.6                
#r "nuget: Xunet, 1.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xunet as a Cake Addin
#addin nuget:?package=Xunet&version=1.0.6

// Install Xunet as a Cake Tool
#tool nuget:?package=Xunet&version=1.0.6                

常用工具库

Xunet 是 .NET 的通用工具库,包含扩展方法、辅助类和一些中间件,用于简化开发和提高工作效率。

Xunet

扩展类

1、日期时间扩展类

// 获取当前时间戳
var timeStamp = DateTime.Now.ToTimeStamp();
// 时间戳转DateTime
var dateTime = timeStamp.ToDateTime();

2、Ffmpeg扩展类

// 音频文件路径
var audio_path = "音频文件路径";
// 获取音频文件时长
var length = audio_path.GetMediaLength("Ffmpeg.exe所在目录,默认当前目录");
// 视频文件路径
var video_path = "视频文件路径";
// 获取视频截图
var image = video_path.CatchVideoImg("目标存储路径", "Ffmpeg.exe所在目录,默认当前目录");

3、HttpClient扩展类

// 接口地址
var url = "https://api.demo.com/test";
// GET请求
var result = await url.HttpGetAsync();
// POST请求(支持application/json和form-data)
var result2 = await url.HttpPostAsync(HttpContentType.ApplicationJson, 
new { id = "参数1", name = "参数2" });

4、Json扩展类

// object对象
var data = new { code = 0, message = "" };
// JSON序列化
var json = data.SerializeObject();
// JSON反序列化
var obj = json.DeserializeObject<object>();

5、随机数扩展类

// 获取8位数随机字符串
// 参数:level,复杂等级,0纯数字,1数字+字母,2数字+字母+特殊字符
var text = 8.NextString(2);

6、加解密扩展类

// 输入字符串
var input = "123456";
// MD5加密
var md5Value = input.ToMD5Encrypt();
// SHA256加密
var sha256Value = input.ToSHA256Encrypt();
// AES加密
var aesValue = input.ToAESEncrypt();
// AES解密
var aesText = aesValue.ToAESDecrypt();
// RSA加密
// 获取RSA公钥和私钥(2048位)
var key = 2048.ToRSASecretKey();
// 公钥加密
var rsaValue = input.ToRSAEncrypt(key.PublicKey);
// 私钥解密
var rsaText = rsaValue.ToRSADecrypt(key.PrivateKey);

7、String扩展类

// 判断是否是null或者空字符串
var isNull = "".IsNullOrEmpty();
// 判断是否非null且非空字符串
var isNotNull = "123456".IsNotNullOrEmpty();

辅助类

1、雪花ID

// 获取雪花Id
var id1 = SnowflakeHelper.NextId();
// 获取雪花Id字符串
var id2 = SnowflakeHelper.NextIdString();
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Xunet:

Package Downloads
Xunet.WinFormium

A Lightweight WinForm Application Framework For .NET

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.23 139 8/16/2024
1.0.22 134 7/3/2024
1.0.21 98 6/28/2024
1.0.20 86 6/25/2024
1.0.19 125 4/10/2024
1.0.18 132 12/15/2023
1.0.17 133 11/28/2023
1.0.16 135 11/27/2023
1.0.15 120 11/27/2023
1.0.14 147 8/8/2023
1.0.13 167 8/7/2023
1.0.12 190 7/13/2023
1.0.11 161 7/4/2023
1.0.10 172 6/12/2023
1.0.9 160 6/8/2023
1.0.8 174 6/8/2023
1.0.7 220 6/7/2023
1.0.6 168 6/6/2023
1.0.5 159 6/6/2023
1.0.4 167 6/5/2023
1.0.3 142 6/5/2023
1.0.2 165 6/5/2023