TJC.Cyclops.Common 2026.7.9.4

dotnet add package TJC.Cyclops.Common --version 2026.7.9.4
                    
NuGet\Install-Package TJC.Cyclops.Common -Version 2026.7.9.4
                    
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="TJC.Cyclops.Common" Version="2026.7.9.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TJC.Cyclops.Common" Version="2026.7.9.4" />
                    
Directory.Packages.props
<PackageReference Include="TJC.Cyclops.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 TJC.Cyclops.Common --version 2026.7.9.4
                    
#r "nuget: TJC.Cyclops.Common, 2026.7.9.4"
                    
#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 TJC.Cyclops.Common@2026.7.9.4
                    
#: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=TJC.Cyclops.Common&version=2026.7.9.4
                    
Install as a Cake Addin
#tool nuget:?package=TJC.Cyclops.Common&version=2026.7.9.4
                    
Install as a Cake Tool

Cyclops.Common 🛠️

“企业级开发的瑞士军刀,开箱即用,少写 80% 的样板代码。”

你是否还在为这些琐事头疼?

  • Excel 导入导出又要手写一遍 NPOI?
  • HTTP 请求想简单调个接口却层层封装?
  • 缓存、日志、文件、字符串、日期、IP、二维码……每个项目都要重新造一遍轮子?

如果是,那 Cyclops.Common 就是为你准备的。

它是一个基于 .NET 8 的通用工具类库,把企业开发里最高频、最琐碎的需求打包成一套顺手工具:从 Excel、HTTP、文件 IO、缓存、日志,到短信、图像、二维码、IP 归属地、拼音转换,应有尽有。它不是框架,而是你的 “开发外挂” —— 直接引用,马上开工。


为什么选择 Cyclops.Common?

痛点 Cyclops.Common 的解法
Excel/CSV 处理繁琐 ExcelUtilCsvUtil 一行导入导出
HTTP 调用封装复杂 HttpClientProxy + 字符串扩展, GET/POST 像呼吸一样自然
缓存没有过期策略 MemoryCache<T> 自带定时清理
日志配置没完没了 Logger 一句打印,log4net 自动接管
文件读写、路径处理总写错 FileUtilPathUtil 把常见操作封成静态方法
需要短信、二维码、IP 定位 SmsSenderImageUtilIPToRegion 直接可用

一分钟预览

using Cyclops.Common;
using Cyclops.Common.Data;
using Cyclops.Common.IO;

// Excel 秒读
using var fs = File.OpenRead("orders.xlsx");
var dt = ExcelUtil.ImportFromStream(fs, v2003: false, sheetName: "sheet1");

// HTTP 秒调
var proxy = new HttpClientProxy();
var json = await proxy.GetAsync("https://api.example.com/data");

// 缓存秒存
var cache = MemoryCache<string>.GetInstance();
cache.Set("user:1001", "active", TimeSpan.FromMinutes(10));

// 文件秒写
FileUtil.WriteString("log.txt", "保存成功");

// 日志秒打
Logger.Info("订单模块", "订单创建成功");

没有废话,只有生产力。


技术栈

  • 目标框架:.NET 8.0
  • 项目类型:类库(Class Library)
  • NuGet 包TJC.Cyclops.Common

核心依赖

包名 版本 用途
Encrypt.Library 2026.6.21.1 加解密
HtmlAgilityPack 1.12.4 HTML 解析
log4net 3.3.2 日志记录
Newtonsoft.Json 13.0.4 JSON 处理
NPOI 2.8.0 Excel/Office
SharpZipLib 1.4.2 压缩解压
SkiaSharp 4.150.0 图像处理
ZXing.Net 0.16.11 二维码
UAParser.Core 4.0.5 User-Agent 解析
Spectre.Console 0.57.2 控制台美化
Microsoft.Extensions.Configuration / DI 10.0.9 配置与依赖注入

安装

dotnet add package TJC.Cyclops.Common

然后在你需要的地方 using 对应的命名空间即可开工。


工具箱全览

字符串与数据转换

StringUtilStringPlusBase64UtilHexConverterNumberUtilDecimalUtilGuidUtilCodeUtilPasswordUtilModelUtilDynamicUtilAnonymousTypeUtil

字符串处理、单位换算、编码解码、密码校验、对象映射……能想到的转换,基本都有。

日期时间

DateTimeUtil + Calendar.ChineseCalendar

格式化、工作日计算、中文星期、农历、节气、生肖,全搞定。

集合与数据结构

CollectionUtilLinqExtentionSmartListPagedListPagedDictionaryThreadSafeListBatcherDataSplitter

分页、线程安全、批量、拆分,集合操作的常见痛点一次解决。

Excel / CSV

Data.ExcelUtilData.CsvUtilDataTableUtil

基于 NPOI 的 Excel 导入导出,流式读取,直接出 DataTable

缓存

MemoryCache<T>IServiceCacheLocalCacheUtil

MemoryCache<T> 自带过期清理,支持泛型;LocalCacheUtil 持久化到本地文件。

⚠️ 注意:MemoryCache<T>IServiceCacheLogger 位于 System 命名空间。

HTTP 通信

HttpClientProxyHttp.HttpExtensionHttp.FormUploadHttp.FileParameter

支持 GET / POST / 上传 / 自定义 Header,字符串还能直接 .HttpGetAsync().HttpPostAsync()

文件 IO

IO.FileUtilIO.PathUtilIO.FileTypeUtilIO.TempFileIO.PersistenceFile

文件读写、路径处理、临时文件、序列化存储,常见操作一行代码。

日志

Logger(命名空间 System)、LogInfoApiLogInfo

基于 log4net,静态调用:Logger.InfoLogger.ErrorLogger.Debug,省事到离谱。

系统与进程

ComputerUtilProcessUtilShellUtilEnvironmentArgsUtilRuntimeUtilServiceUtilCallContext

机器信息、进程管理、Shell 执行、环境参数、运行时信息,系统级操作也不在话下。

反射与高性能

ReflectionUtilFastILUtilFastCopyEnumUtilBaseSingleInstance<T>

反射不卡、枚举好读、单例基类随拿随用。

网络与 IP

IPUtilLANUtilIPToRegion.IPRegion

IP 归属地查询基于 ip2region,本地离线解析,无需联网。

图像与二维码

ImageUtil(SkiaSharp)、ZXing 二维码

图片处理、二维码生成与识别,直接嵌入业务代码。

短信服务

Sms.SmsSenderSms.SmsOption

短信发送抽象,配置化接入。

安全与防重放

AraReplayAttacksUtilAntiReplayAttacks.AraInfo

接口安全,防重放攻击。

配置与常量

ConfigUtilNacosConfigUtilConsts.*

配置文件、Nacos 配置中心、项目常量,统一管理。

错误处理

Errors.FriendlyExceptionErrors.EnumErrorCode

业务异常规范化,前端拿到错误码,后端抛出友好提示。

事件总线接口

EventBus.IEventBusIEventDataIEventHandler<T>

定义事件总线契约,具体实现可由上层框架注入。

其他宝藏

SerializeUtilStreamUtilZipUtilTracerTryUtilTokenUtilEmailUtilConsoleUtilNPinyin.Pinyin

序列化、流、压缩、追踪、Token、邮件、控制台、拼音转换……这里藏了不少小惊喜。


实战示例

Excel 导入:从混乱到清晰

using Cyclops.Common.Data;
using System.Data;

DataTable? dt;
using (var fs = File.OpenRead("orders.xlsx"))
{
    dt = ExcelUtil.ImportFromStream(fs, v2003: false, sheetName: "sheet1", hasHeader: true);
}

没有样板代码,只有一行核心调用。

HTTP 请求:像写本地方法一样写远程调用

using Cyclops.Common;
using Cyclops.Common.Http;

var client = new HttpClientProxy();

// 普通 GET
string html = await client.GetAsync("https://api.example.com/data");

// 泛型反序列化
var user = await client.GetAsync<UserDto>("https://api.example.com/user/1");

// POST 对象,自动转 JSON
var result = await client.PostAsync("https://api.example.com/order", new { Id = 1, Name = "VIP" });

// 更懒的写法:字符串扩展
string data = await "https://api.example.com/data".HttpGetAsync();

缓存:自带过期,不用管GC

using System;

var cache = MemoryCache<string>.GetInstance();

cache.Set("session:123", "user-data", TimeSpan.FromMinutes(30));

var value = cache.Get("session:123");

文件操作:读写、序列化、删除一把梭

using Cyclops.Common.IO;

// 读文本
string content = FileUtil.ReadString("readme.txt");

// 写文本
FileUtil.WriteString("output.txt", "Hello Cyclops!");

// 对象存文件
FileUtil.Write("config.json", new { Host = "localhost", Port = 5000 });

// 读对象
var config = FileUtil.Read<Config>("config.json");

// 文件存在吗?
bool exists = FileUtil.Exists("output.txt");

日志:三行配置,一行打印

using System;

Logger.Info("订单模块", "订单 10086 创建成功");
Logger.Error("支付模块", exception, "支付回调处理失败");
Logger.Debug("调试", $"耗时 {elapsedMs}ms");

使用前请确保项目根目录有 log4net.config

日期时间:告别手撕时间逻辑

using Cyclops.Common;

var now = DateTimeUtil.Now;
string weekday = DateTimeUtil.GetChineseWeekDay(now);     // 星期四
int workDays = DateTimeUtil.GetWorkDays(now, now.AddDays(10));

业务异常:让错误也优雅

using Cyclops.Common.Errors;

try
{
    throw new FriendlyException(EnumErrorCode.InvalidParameter, "手机号格式不正确");
}
catch (FriendlyException ex)
{
    Console.WriteLine($"[{ex.ErrorCode}] {ex.Message}");
}

事件总线:接口先行,实现灵活

using Cyclops.Common.EventBus;

public class UserCreatedEvent : IEventData
{
    public string UserId { get; set; } = string.Empty;
    public string UserName { get; set; } = string.Empty;
}

public class UserCreatedHandler : IEventHandler<UserCreatedEvent>
{
    public Task HandleAsync(UserCreatedEvent e)
    {
        Console.WriteLine($"欢迎新用户:{e.UserName}");
        return Task.CompletedTask;
    }
}

// IEventBus 的具体实现由上层框架或业务项目注入

使用小贴士

  1. 命名空间别搞错Cyclops.Common 是根命名空间,但具体工具分散在 Cyclops.Common.DataCyclops.Common.IOCyclops.Common.HttpCyclops.Common.SmsCyclops.Common.ErrorsCyclops.Common.EventBusCyclops.Common.CalendarCyclops.Common.ConstsCyclops.Common.IPToRegionCyclops.Common.AntiReplayAttacksCyclops.Common.NPinyin 等子命名空间;MemoryCache<T>IServiceCacheLogger 位于 System
  2. 日志先配 log4netLogger 依赖 log4net.config,否则可能找不到输出目标。
  3. 线程安全要选型:多线程场景优先 ThreadSafeList、并发字典或 MemoryCache<T>
  4. 缓存设过期:缓存不是无限内存,请按业务设置合理过期时间。
  5. 配置走 Nacos:经常变化的配置用 NacosConfigUtil,避免改配置就发版。
  6. 第三方库版本:NPOI、Newtonsoft.Json、SkiaSharp 等升级时请检查兼容性。

许可证

MIT License


Cyclops.Common —— 让 .NET 企业开发更简单、更快、更爽。 🚀

如果你也觉得重复造轮子很无聊,那就把它加进你的工具箱吧。

Product 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (25)

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

Package Downloads
TJC.Cyclops.Orm

企服版框架中ORM核心,基于YitIdHelper、Mapster、SqlSugar封装

TJC.Cyclops.LogLib

企服版框架集成日志核心

TJC.Cyclops.Web.Core

企服版框架中api核心功能项目,基于aspnetcore集成di、jwt、swagger、codefirtst、支持多种常见数据库、nacos配置中心、统一接口回复参数、全局异常捕获、全局接口日志、防重放攻击、图形验证码、快捷上下文对象、上传下载、数据导入导出等功能

TJC.Cyclops.Speech

语音转换工具类

TJC.Cyclops.Redis

企服版框架redis sdk

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.7.9.4 0 7/9/2026
2026.7.9.3 36 7/9/2026
2026.7.9.2 50 7/9/2026
2026.7.9.1 69 7/9/2026
2026.7.8.2 222 7/8/2026
2026.7.8.1 231 7/8/2026
2026.7.6.1 420 7/6/2026
2026.7.1.1 527 7/1/2026
2026.6.24.1 548 6/24/2026
2026.6.23.1 524 6/23/2026
2026.6.22.2 529 6/22/2026
2026.6.22.1 526 6/22/2026
2026.6.11.2 712 6/11/2026
2026.6.11.1 714 6/11/2026
2026.6.9.4 711 6/9/2026
2026.6.9.3 700 6/9/2026
2026.6.9.2 704 6/9/2026
2026.6.9.1 683 6/9/2026
2026.6.8.3 690 6/8/2026
2026.6.8.2 630 6/8/2026
Loading failed

企服版框架工具类项目,三方引用包主要有:Encrypt.Library、HtmlAgilityPack、ICSharpCode.SharpZipLib、log4net、Newtonsoft.Json、NPOI、SkiaSharp、ZXing等