CloudYxt.Common
2.2.2
dotnet add package CloudYxt.Common --version 2.2.2
NuGet\Install-Package CloudYxt.Common -Version 2.2.2
<PackageReference Include="CloudYxt.Common" Version="2.2.2" />
paket add CloudYxt.Common --version 2.2.2
#r "nuget: CloudYxt.Common, 2.2.2"
// Install CloudYxt.Common as a Cake Addin #addin nuget:?package=CloudYxt.Common&version=2.2.2 // Install CloudYxt.Common as a Cake Tool #tool nuget:?package=CloudYxt.Common&version=2.2.2
云享通.Net Core基础处理类扩展库
云享通.Net Core基础处理类扩展库,如:常见的类型快捷方法和KTDatatable接收方法
ConcurrentPipelineTask不重复并行独立线程运算队列
类似生产消费队列,但能控制并行独立处理线程数和筛选不重复数据,同时支持同步和异步运算方法,以下为BackgroundWorker中的使用示例:
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}");
}
}
}
根据文件编码读取文件内容
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:普通扩展参数
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- AutoMapper (>= 12.0.1)
- System.Text.Encoding.CodePages (>= 6.0.0)
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.DingTalk
云享通.Net Core钉钉机器人扩展库(可支持签名) 1.1.0 支持CloudYxt.Base数据类型 |
|
CloudYxt.Models.WeiXin
云享通.Net Corec微信开发SDK数据结构,注意:当前仅包含核心数据结构SDK,未包含全部开发SDK。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.2 | 424 | 3/19/2024 |
2.2.1 | 394 | 10/7/2023 |
2.2.0 | 192 | 8/2/2023 |
2.1.1 | 485 | 4/21/2023 |
2.1.0 | 166 | 4/21/2023 |
2.0.0 | 1,995 | 7/14/2022 |
1.0.8 | 6,592 | 11/26/2021 |
1.0.7 | 4,204 | 6/7/2021 |
1.0.6 | 2,260 | 2/23/2021 |
1.0.5 | 488 | 2/23/2021 |
1.0.4 | 795 | 1/5/2021 |
1.0.3 | 966 | 8/26/2020 |
1.0.2 | 953 | 7/9/2020 |
1.0.1 | 1,650 | 6/12/2020 |
1.0.0 | 784 | 6/12/2020 |
云享通.Net Core基础处理类扩展库,如:常见的类型快捷方法和KTDatatable接收方法
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编解码快捷方法