VOOZH about

URL: https://www.nuget.org/packages/CloudYxt.Common/

⇱ NuGet Gallery | CloudYxt.Common 3.2.0




👁 Image
CloudYxt.Common 3.2.0

dotnet add package CloudYxt.Common --version 3.2.0
 
 
NuGet\Install-Package CloudYxt.Common -Version 3.2.0
 
 
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="CloudYxt.Common" Version="3.2.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CloudYxt.Common" Version="3.2.0" />
 
Directory.Packages.props
<PackageReference Include="CloudYxt.Common" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CloudYxt.Common --version 3.2.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CloudYxt.Common, 3.2.0"
 
 
#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.
#:package CloudYxt.Common@3.2.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CloudYxt.Common&version=3.2.0
 
Install as a Cake Addin
#tool nuget:?package=CloudYxt.Common&version=3.2.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

云享通.Net Core基础处理类扩展库

云享通.Net Core基础处理类扩展库,如:常见的类型快捷方法和KTDatatable接收方法

ConcurrentPipelineTask不重复并行独立线程运算队列

类似生产消费队列,但能控制并行独立处理线程数和筛选不重复数据,同时支持同步和异步运算方法,以下为BackgroundWorker中的使用示例:

方法一(自己完成生产、消费线程Task):

public class Worker_Pipeline : BackgroundService
{
 private readonly ILogger<Worker_Pipeline> _logger;

 public Worker_Pipeline(ILogger<Worker_Pipeline> logger)
 {
 _logger = logger;
 }

 //BackgroundWorker的主线程ExecuteAsync
 protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 {
 int maxConcurrentAccess = 5; // 设置最大允许的并发访问数量

 //初始化默认最大为100个线程的队列
 //var processor = new ConcurrentPipelineTask<int>();

 //指定最大线程和对象比对方法的队列
 var processor = new ConcurrentPipelineTask<int>(maxConcurrentAccess, (item1, item2) => { return item1 == item2; });

 // 启动生产者和消费者任务
 var producerTask = ProduceNumbers(processor, stoppingToken);
 var consumerTask = ConsumeNumbers(processor, stoppingToken);

 // 等待所有任务完成
 await Task.WhenAll(producerTask, consumerTask);

 _logger.LogInformation("Worker End at: {time}", DateTimeOffset.Now);
 }

 //测试生产子线程
 static async Task ProduceNumbers(ConcurrentPipelineTask<int> processor, CancellationToken stoppingToken)
 {
 var i = 0;
 while (!stoppingToken.IsCancellationRequested)
 {
 i++;
 while (i % 20 != 0) //每次生产20个数
 {
 // 等待 500 毫秒模拟生产过程
 //await Task.Delay(500);

 // 生产数据
 var produce = await processor.ProduceAsync(i); //同步方法为processor.Produce(i);
 Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} Produce: {i} -> {produce}");

 //测试重复元素时使用
 //var y = i / 2;
 //processor.Produce(y);
 //Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} Produce: {y}");
 }

 await Task.Delay(TimeSpan.FromMinutes(4), stoppingToken);
 }
 }

 //测试消费子线程
 static async Task ConsumeNumbers(ConcurrentPipelineTask<int> processor, CancellationToken stoppingToken)
 {
 var i = 0;
 while (!stoppingToken.IsCancellationRequested)
 {
 i++;
 Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} Consumer Line Start:{i}");
 Console.WriteLine($"当前运行的filledSet -> {string.Join(',', processor.filledConcurrent)}");

 //异步方法
 await processor.ConsumeAsync(async (number, stopping) => //同步方法为processor.Consume
 {
 // 模拟消费过程
 await Task.Delay(700 * number, stopping);

 // 进行数据运算(这里简单实现整数加倍)
 var result = number * 2;

 // 输出结果
 Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} Consumer: {number} -> {result}");

 return true;
 }, stoppingToken);

 await Task.Delay(1000);
 Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} Consumer Line End:{i}");
 }

 }
}

方法二(使用内置引擎线程,只需完成生产、消费实现部分):

public class Worker_Pipeline : BackgroundService
{
 private readonly ILogger<Worker_Pipeline> _logger;

 public Worker_Pipeline(ILogger<Worker_Pipeline> logger)
 {
 _logger = logger;
 }

 //BackgroundWorker的主线程ExecuteAsync
 protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 {
 int maxConcurrentAccess = 5; // 设置最大允许的并发访问数量

 //初始化默认最大为100个线程的队列
 //var processor = new ConcurrentPipelineTask<int>();

 //指定最大线程和对象比对方法的队列
 var processor = new ConcurrentPipelineTask<int>(maxConcurrentAccess, (item1, item2) => { return item1 == item2; });

 // 启动生产者和消费者任务(同时支持同步实现和async异步实现)
 await processor.ExecuteAsync(async (stoppingToken) =>
 {
 // 持续生产实现代码
 await Task.Delay(100, stoppingToken);

 var allnums = new List<int>();
 while (allnums.Count < 20)
 {
 allnums.Add(new Random().Next(1000, 9999));
 }
 return allnums;
 }, async (number, stoppingToken) =>
 {
 Console.WriteLine($"{DateTime.Now} consume wait {number}");
 // 模拟消费过程
 await Task.Delay(number, stoppingToken);

 // 进行数据运算(这里简单实现整数加倍)
 var result = number * 2;

 // 输出结果
 Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} Consumer: {number} -> {result}");

 }, stoppingToken, async (stat, items, works) =>
 {
 await Task.Delay(1);
 Console.WriteLine($"{DateTime.Now} onwork {stat} items:{items.Count} works:{works.Count} -> {string.Join(',', works)}");
 });

 _logger.LogInformation("Worker End at: {time}", DateTimeOffset.Now);
 }

}

根据文件编码读取文件内容

var html = HtmlFile.ReadAllHtml("文件路径");

Console.WriteLine(html);

拼音处理

//汉字转拼音缩写
var py = CHS2PinYin.GetPYString("中文");

//取单个字符的拼音声母
var pySheng = CHS2PinYin.GetPYChar("中");

//将指定中文字符串转换为拼音形式
var pyAll = CHS2PinYin.Convert("中文说明");

//...

其他常规工具

//判断List是否为空
var mylist = new List<string>();
var isEmpty = mylist.IsEmpty();

//获取MD5
var md5 = "测试的字符".MD5();

//将null转换为空字符
var obj = null;
var str = obj.null2Empty();

//...

datatable相关

datatableDictRequest:字典扩展参数 datatableTRequest:指定扩展参数T datatableRequest:普通扩展参数

XWebClient基于WebClient的扩展(已废弃)

using (var client = new XWebClient())
{
 client.Timeout = 120;
 //同步方法
 client.PostJson(……);
 //异步方法
 await client.PostJsonAsync(……);
}

HttpClient扩展(PostJson建议使用此扩展)

var client = new HttpClient();
//同步方法
client.PostJson<T>(……);
//异步方法
await client.PostJsonAsync<T>(……);

Newtonsoft.Json扩展

JParse:System.Text.Json和Newtonsoft.Json之间的转换 OrderedContractResolver:按字母顺序排序JSON序列化字段

StreamReverseReader反向按行读取文本文件

同步用法:

using var reader = new StreamReverseReader("log.txt", Encoding.UTF8);
string? line;
while ((line = reader.ReadLine()) != null)
{
 Console.WriteLine(line);
}

异步用法:

await using var reader = new StreamReverseReader("log.txt", Encoding.UTF8);
string? line;
while ((line = await reader.ReadLineAsync()) != null)
{
 Console.WriteLine(line);
}
Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on CloudYxt.Common:

Package Downloads
CloudYxt.Models

云享通.Net Core常用WEBAPI数据类型及MongoDB扩展库,如:MongoDB常用方法、基于MongoDB的对象存储OSS方法,MongoDB索引自维护等。

CloudYxt.ClickHouse

云享通.Net Corec基于ClickHouse.Ado驱动建立常规数据操作库。

CloudYxt.Redis

云享通.Net Core针对Redis扩展操作库

CloudYxt.Models.WeiXin

云享通.Net Corec微信开发SDK数据结构,注意:当前仅包含核心数据结构SDK,未包含全部开发SDK。

CloudYxt.DingTalk

云享通.Net Core钉钉机器人扩展库(可支持签名) 1.1.0 支持CloudYxt.Base数据类型

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.0 157 4/16/2026
3.1.2 359 12/25/2025
3.1.1 354 4/18/2025
3.0.0 344 2/20/2025
2.3.0 320 1/3/2025
2.2.2 789 3/19/2024
2.2.1 643 10/7/2023
2.2.0 339 8/2/2023
2.1.1 740 4/21/2023
2.1.0 345 4/21/2023
2.0.0 2,324 7/14/2022
1.0.8 7,200 11/26/2021
1.0.7 4,843 6/7/2021
1.0.6 2,707 2/23/2021
1.0.5 724 2/23/2021
1.0.4 1,061 1/5/2021
1.0.3 1,287 8/26/2020
1.0.2 1,241 7/9/2020
1.0.1 1,999 6/12/2020
Loading failed

云享通.Net Core基础处理类扩展库,如:常见的类型快捷方法和KTDatatable接收方法

3.2.0
由于AutoMapper商业化,且旧版本都标记为“脆弱”,去除其依赖,建议改用Mapperly

3.1.2
增加pageResponse的JsonConstructor

3.1.1
增加StreamReverseReader,反向文件按行读取方法

3.0
更改.net编译版本,迁移原CloudYxt.Models关于XWebClient和Newtonsoft.Json至此包,CloudYxt.Models将主要完成针对MongoDB的扩展

2.3
改进ConcurrentPipelineTask,增强容错稳定性,增加ExecuteAsync方法可直接挂载生产消费线程

2.2.2
增加HtmlFile.ReadAllHtml可以从数据流或字节数组读取

2.2.1
datatableResponse输出增加sortAvails可选可排序字段名属性;null2Empty方法增加可自定义默认字符

2.2
增加ConcurrentPipelineTask不重复并行独立线程运算队列

2.1.1
修复字典名称BUG

2.1.0
增加KTDatatable自定义的datatableDictRequest和datatableTRequest<T>接收方法以方便接收过滤参数,同时新增字典的TryGetFilterString方法以接收字符串值

2.0.0
升级包目标为netstandard2.1,升级nuget,调整中文拼音的自适应编码方法

1.0.8
增加AutoMapper类型映射扩展方法,增加DateTime?的ToUniversalTime()扩展方法

1.0.7
增加KTDatatable自定义filter参数和Description说明

1.0.6
紧急增加AES解密使用BASE64字符方法

1.0.5
增加AES-CBC、SHA1快捷算法

1.0.4
增加中文转拼音模块

1.0.3
增加中文字符按两个字符计算和截取方法
增加独立分页计算参数方法

1.0.2
增加Unicode编解码快捷方法