Smart.Helper
3.5.5
dotnet add package Smart.Helper --version 3.5.5
NuGet\Install-Package Smart.Helper -Version 3.5.5
<PackageReference Include="Smart.Helper" Version="3.5.5" />
<PackageVersion Include="Smart.Helper" Version="3.5.5" />
<PackageReference Include="Smart.Helper" />
paket add Smart.Helper --version 3.5.5
#r "nuget: Smart.Helper, 3.5.5"
#:package Smart.Helper@3.5.5
#addin nuget:?package=Smart.Helper&version=3.5.5
#tool nuget:?package=Smart.Helper&version=3.5.5
Smart.Helper
<a name="english"></a>
English
Smart.Helper is a .NET utility library for byte buffers, conversions, checksums, compression, network helpers, caching, logging, assembly loading, and async synchronization. It supports .NET 8, 9, and 10.
Features
SmartByteBuffer: dynamic byte buffer with endian support.SmartConvert: base conversion, hex conversion, string reversal, JWT payload decoding, and struct/byte conversions.SmartCompress: ZLib, GZip, and Deflate compression helpers.SmartNetwork: IP, MAC, ping, gateway, and TCP port helpers.SmartLog: simple file logger with optional background writing.SmartAutoResetEvent: async auto-reset event with timeout and cancellation support.SmartCache,BusLock,BusLockManager,SmartAssemblyLoader, CRC16, and CRC32 helpers.
Installation
dotnet add package Smart.Helper
Examples
using Smart.Helper;
var buffer = new SmartByteBuffer(isLittleEndian: true);
buffer.SetInt32(1024);
buffer.SetString("Hello");
buffer.Position = 0;
int value = buffer.GetInt32();
string text = buffer.GetString(5);
byte[] data = buffer.ToArray();
byte[] bytes = SmartConvert.HexStringToByteArray("AA BB CC", " ");
string hex = SmartConvert.ByteArrayToHexString(bytes, " ");
string binary = SmartConvert.ConvertBase("FF", 16, 2);
byte[] raw = Encoding.UTF8.GetBytes("Some data to compress");
byte[] compressed = SmartCompress.GZipCompress(raw);
byte[] decompressed = SmartCompress.GZipDecompress(compressed);
var ips = SmartNetwork.GetAllValidIPAddresses(IPTypeFlags.IPv4);
bool pingOk = await SmartNetwork.PingAsync("www.google.com");
bool portOpen = await SmartNetwork.IsTcpPortOpenAsync("127.0.0.1", 80);
using var logger = new SmartLog("MyService");
logger.StartThread();
logger.Info("Service started successfully.");
logger.Error("An error occurred.");
logger.StopThread();
using var evt = new SmartAutoResetEvent();
try
{
await evt.WaitAsync(TimeSpan.FromSeconds(5));
}
catch (TimeoutException)
{
Console.WriteLine("Wait timed out.");
}
evt.Set();
<a name="chinese"></a>
中文
Smart.Helper 是一个 .NET 工具库,提供字节缓冲、数据转换、校验、压缩、网络工具、缓存、日志、程序集加载和异步同步原语等能力,兼容 .NET 8/9/10。
功能特性
SmartByteBuffer:支持大小端的动态字节缓冲区。SmartConvert:进制转换、Hex 转换、字符串反转、JWT 内容解码、结构体与字节数组互转。SmartCompress:ZLib、GZip、Deflate 压缩与解压。SmartNetwork:IP、MAC、Ping、默认网关和 TCP 端口检测。SmartLog:简单文件日志,支持后台写入。SmartAutoResetEvent:支持超时和取消令牌的异步自动重置事件。SmartCache、BusLock、BusLockManager、SmartAssemblyLoader、CRC16、CRC32 等辅助工具。
安装
dotnet add package Smart.Helper
示例
using Smart.Helper;
var buffer = new SmartByteBuffer(isLittleEndian: true);
buffer.SetInt32(1024);
buffer.SetString("Hello");
buffer.Position = 0;
int value = buffer.GetInt32();
string text = buffer.GetString(5);
byte[] data = buffer.ToArray();
byte[] bytes = SmartConvert.HexStringToByteArray("AA BB CC", " ");
string hex = SmartConvert.ByteArrayToHexString(bytes, " ");
string binary = SmartConvert.ConvertBase("FF", 16, 2);
byte[] raw = Encoding.UTF8.GetBytes("Some data to compress");
byte[] compressed = SmartCompress.GZipCompress(raw);
byte[] decompressed = SmartCompress.GZipDecompress(compressed);
var ips = SmartNetwork.GetAllValidIPAddresses(IPTypeFlags.IPv4);
bool pingOk = await SmartNetwork.PingAsync("www.baidu.com");
bool portOpen = await SmartNetwork.IsTcpPortOpenAsync("127.0.0.1", 80);
using var logger = new SmartLog("MyService");
logger.StartThread();
logger.Info("服务启动成功。");
logger.Error("发生了一个错误。");
logger.StopThread();
using var evt = new SmartAutoResetEvent();
try
{
await evt.WaitAsync(TimeSpan.FromSeconds(5));
}
catch (TimeoutException)
{
Console.WriteLine("等待超时。");
}
evt.Set();
Developed by zenglei
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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 is compatible. 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Smart.Helper:
| Package | Downloads |
|---|---|
|
Smart.Modbus
Modbus协议封装库,提供ModbusRTU、ModbusTCP和ModbusASCII的组帧、响应校验、响应解析、数据缓冲,不涉及通信;分为ModbusMaster和ModbusSlave,分别用于Modbus主站和从站 |
|
|
Smart.Ports
Smart.Ports是一个统一的通信端口类库,提供了一致的接口来操作不同类型的通信端口,包括串口(SerialPort)、TCP客户端(TcpClient)、TCP服务端(TcpServer)和UDP节点(Udp)。该类库使用工厂模式简化端口创建,并通过继承关系提供特定端口类型的扩展功能。 Smart.Ports is a unified communication port library that provides a consistent interface for operating different types of communication ports, including SerialPort, TcpClient, TcpServer, and Udp. The library uses the factory pattern to simplify port creation and provides extended functionality for specific port types through inheritance. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.5.5 | 41 | 5/16/2026 |
| 3.5.4 | 253 | 3/5/2026 |
| 3.5.3 | 111 | 3/5/2026 |
| 3.5.1 | 168 | 2/28/2026 |
| 3.5.0 | 168 | 2/7/2026 |
| 3.4.7 | 145 | 1/10/2026 |
| 3.4.6 | 135 | 1/10/2026 |
| 3.4.5 | 140 | 12/30/2025 |
| 3.4.4 | 328 | 10/15/2025 |
| 3.4.3 | 311 | 9/3/2025 |
| 3.4.2 | 344 | 7/20/2025 |
| 3.4.1 | 169 | 7/19/2025 |
| 3.4.0 | 269 | 7/13/2025 |
| 3.3.3 | 253 | 7/10/2025 |
| 3.3.2 | 441 | 6/8/2025 |
| 3.3.1 | 253 | 6/1/2025 |
| 3.3.0 | 220 | 6/1/2025 |
| 3.2.0 | 319 | 5/7/2025 |
| 3.1.2 | 225 | 2/28/2025 |
| 3.1.1 | 254 | 2/26/2025 |