RuoVea.ExUtil
7.0.1.3
See the version list below for details.
dotnet add package RuoVea.ExUtil --version 7.0.1.3
NuGet\Install-Package RuoVea.ExUtil -Version 7.0.1.3
<PackageReference Include="RuoVea.ExUtil" Version="7.0.1.3" />
<PackageVersion Include="RuoVea.ExUtil" Version="7.0.1.3" />
<PackageReference Include="RuoVea.ExUtil" />
paket add RuoVea.ExUtil --version 7.0.1.3
#r "nuget: RuoVea.ExUtil, 7.0.1.3"
#:package RuoVea.ExUtil@7.0.1.3
#addin nuget:?package=RuoVea.ExUtil&version=7.0.1.3
#tool nuget:?package=RuoVea.ExUtil&version=7.0.1.3
🔧 RuoVea.ExUtil 详细功能分解
1. 加密安全模块
AES加解密 (UtilAes)
// 支持的功能:
- AES加密(支持多种模式:CBC, ECB等)
- AES解密
- 密钥生成和管理
- 向量(IV)处理
- 编码格式支持(Base64, Hex等)
RSA工具类 (UtilRsa)
// 支持的功能:
- RSA密钥对生成
- 公钥加密/私钥解密
- 私钥签名/公钥验证
- 证书格式支持(PEM, XML)
- 大文件分段加密
2. 类型转换扩展 - 详细方法
数值转换扩展
// 完整的方法签名:
int ToInt(this object data) // 对象转int
int? ToIntOrNull(this object data) // 对象转可空int
double ToDouble(this object data) // 对象转double
double ToDouble(this object data, int digits) // 对象转double并四舍五入
double? ToDoubleOrNull(this object data) // 对象转可空double
decimal ToDecimal(this object data) // 对象转decimal
decimal ToDecimal(this object data, int digits) // 对象转decimal并四舍五入
decimal? ToDecimalOrNull(this object data) // 对象转可空decimal
decimal? ToDecimalOrNull(this object data, int digits)// 对象转可空decimal并四舍五入
日期时间转换
DateTime ToDate(this object data) // 对象转DateTime
DateTime? ToDateOrNull(this object data) // 对象转可空DateTime
bool ToBool(this object data) // 对象转bool
bool? ToBoolOrNull(this object data) // 对象转可空bool
字节和字符串转换
byte[] GetBytes(this string str) // 字符串转byte[]
string GetString(this byte[] bytes) // byte[]转字符串
string ToQueryString(this Dictionary<string, string> dict, bool urlEncode = true)
string UrlEncode(this string str) // URL编码
3. 日期时间扩展 - 完整格式化
日期格式化方法
string ToDateTimeString(this DateTime dateTime, bool isRemoveSecond = false)
// 输出: "2024-01-01 12:30:45" 或 "2024-01-01 12:30"
string ToDateString(this DateTime dateTime) // "2024-01-01"
string ToTimeString(this DateTime dateTime) // "12:30:45"
string ToMillisecondString(this DateTime dateTime) // "2024-01-01 12:30:45.123"
// 中文格式
string ToChineseDateString(this DateTime dateTime) // "2024年01月01日"
string ToChineseDateTimeString(this DateTime dateTime, bool isRemoveSecond = false)
// 输出: "2024年01月01日 12时30分45秒" 或 "2024年01月01日 12时30分"
时间戳处理
long GetTimeStamp(this DateTime dateTime) // 获取时间戳
DateTime GetTimeSpmpToDate(this object timeStamp) // 时间戳转日期
4. JSON处理扩展 - 完整序列化
JSON转换方法
object Json2Obj(this string Json) // JSON转对象
string Json2Str(this object obj, bool long2Str = true) // 对象转JSON字符串
string Json2Str(this object obj, string datetimeformats, bool long2Str = true)
// 泛型反序列化
T ToObject<T>(this string Json) // JSON转指定类型
List<T> ToList<T>(this string Json) // JSON转列表
DataTable ToTable(this string Json) // JSON转DataTable
JObject ToJObject(this string Json) // JSON转Linq对象
// 集合序列化
string ListToJson<T>(this IList<T> list) // 列表转JSON
string ToJson(this object jsonObject) // 对象转JSON
string ToJson(this IEnumerable array) // 集合转JSON
string ToArrayString(this IEnumerable array) // 集合转数组字符串
// 数据相关序列化
string ToJson(this DataSet dataSet) // DataSet转JSON
string ToJson(this DataTable dt) // DataTable转JSON
string ToJson(this DataTable dt, string jsonName) // DataTable转JSON(带名称)
string ReaderJson(this IDataReader dataReader) // DataReader转JSON
高级JSON处理
T DeserializeObject<T>(this string entityString) // 反序列化
string Serialize(this object obj, JsonSerializerSettings formatDate = null)
LongToStringConverter // Long类型精度处理转换器
5. 字符串处理 - 详细功能
字符串转换和格式化
string Splice<T>(this IEnumerable<T> list, string quotes = "", string separator = ",")
// 示例:列表["a","b"] => "a,b" 或 "'a','b'"
string FirstUpper(this string value) // 首字母大写
string FirstLower(this string value) // 首字母小写
string ToCamel(this string value, bool keepOriginalCase = false, bool firstCharacterUpper = true) // 转驼峰命名,支持灵活大小写控制
string ToCamelAny(this string value, bool keepOriginalCase = false, bool firstCharacterUpper = true, bool eachPartUpper = true) // 转驼峰(去除下划线),支持灵活大小写控制
字符串内容检测
bool ContainsChinese(this string text) // 是否包含中文
bool ContainsNumber(this string text) // 是否包含数字
string Distinct(this string value) // 字符串去重
string Truncate(this string text, int length, int endCharCount = 0, string endChar = ".")
// 字符串截断,支持末尾字符处理
高级字符串操作
string[] GetHtmlImageUrlList(this string sHtmlText) // 提取HTML图片URL
string FilterEmoji(this string str) // 过滤Emoji表情
List<long> StrToListLong(this string str) // 字符串转long列表
List<string> StrToListString(this string str) // 字符串转string列表
// 正则处理
bool IsMatch(this string value, string pattern, RegexOptions options)
bool IsMatch(this string value, string pattern)
// 时间字符串处理
(string beginTime, string endTime) Splitting(this string timeStr, char split = '/')
// 时间范围分割:"2024-01-01/2024-01-31" => ("2024-01-01", "2024-01-31")
6. LINQ和表达式树 - 高级功能
表达式构建
// 属性表达式
Expression Property(this Expression expression, string propertyName)
// 示例:构建 x => x.Name 的表达式
// 条件表达式
Expression AndAlso(this Expression left, Expression right) // 逻辑与
Expression GreaterThan(this Expression left, Expression right) // 大于比较
// 方法调用表达式
Expression Call(this Expression instance, string methodName, params Expression[] arguments)
Lambda表达式组合
Expression<T> ToLambda<T>(this Expression body, params ParameterExpression[] parameters)
Expression<Func<T, bool>> True<T>() // 永远为true的表达式
Expression<Func<T, bool>> False<T>() // 永远为false的表达式
// 表达式组合
Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
// 表达式合并
static Expression<T> Compose<T>(this Expression<T> first, Expression<T> second, Func<Expression, Expression, Expression> merge)
参数重绑定
ParameterRebinder // 表达式参数重绑定器
// 用于处理表达式树中的参数替换和合并
7. 系统监控和Shell - 详细功能
服务器信息监控 (ExMachine)
dynamic GetMachineUseInfo()
// 返回:CPU使用率、内存使用、磁盘IO、网络流量等
dynamic GetMachineBaseInfo()
// 返回:操作系统、处理器、内存大小、磁盘信息等
string GetCpuRate() // 获取CPU使用率百分比
string GetDiskRate() // 获取磁盘使用率百分比
dynamic GetRamInfo()
// 返回:总内存、已用内存、可用内存、内存使用率等
Shell命令执行 (ExShell)
string Bash(string command)
// 执行Bash命令,支持Linux/macOS系统
string Cmd(string fileName, string args)
// 执行CMD命令,支持Windows系统
// fileName: 可执行文件或命令
// args: 命令行参数
8. 时间操作工具 - 完整功能
日期计算和转换
// 日期获取和计算
string GetDate(int i) // 当前日期加减天数
string GetDate(int i, string dateformat) // 指定格式的日期计算
// 时间周期计算
int GetDaysOfYear(int iYear) // 年份天数
int GetDaysOfMonth(int iYear, int Month) // 月份天数
int GetWeekAmount(int year) // 年份周数
int GetWeekOfYear(DateTime dt) // 日期所在周数
// 时间范围处理
void WeekRange(int year, int weekOrder, ref DateTime firstDate, ref DateTime lastDate)
// 根据年份和周数获取该周的起止日期
时间差计算
int DiffDays(DateTime dtfrm, DateTime dtto) // 相差天数
int DiffHours(DateTime dtfrm, DateTime dtto) // 相差小时数
int DiffMinutes(DateTime dtfrm, DateTime dtto) // 相差分钟数
本地化时间格式
string GetChineseWeekDay(int y, int m, int d) // 中式星期:"日","一","二"...
string GetChineseDateTime(DateTime dt) // 中文时间格式
int GetNumberWeekDay(DateTime dt) // 数字星期(1-7)
9. 数据验证系统 - 完整验证规则
联系方式和身份验证
// 手机号验证细分
bool IsChinaMobilePhone(string value) // 中国移动号码
bool IsChinaUnicomPhone(string value) // 中国联通号码
bool IsChinaTelecomPhone(string value) // 中国电信号码
// 邮箱验证
bool IsEmail(this string str) // 普通邮箱验证
bool IsQqEmail(this string str) // QQ邮箱专门验证
// 身份验证
bool IsIdCard(string value) // 身份证号码验证
bool IsBandCard(string value) // 银行卡号验证(16/19位)
密码强度验证
bool IsPasswordOne(string value) // 密码格式1:6-25位含特殊字符
bool IsPasswordOne(string value, int min, int max) // 可自定义长度的密码格式1
bool IsPasswordTwo(string value) // 密码格式2:6-25位含特殊字符
bool IsPassworld(object value, int minLength = 8, int maxLength = 32)
bool IsSuperPassworld(object value, int minLength = 8, int maxLength = 32)
网络相关验证
bool IsUrl(string value) // URL地址验证
bool IsUri(string value) // URI标识验证
bool IsMainDomainUrl(string value) // 主域名或www开头验证
bool IsMainDomain(string value) // 主域名验证
bool IsDomain(string value) // 域名格式验证
bool IsIpAddress(string value) // IP地址验证
bool IsMac(string value) // MAC地址验证
业务数据验证
bool IsVersion(string value, int length = 5) // 版本号验证
bool IsChinesePostalCode(string value) // 中国邮政编码验证
bool IsColorValue(string value) // 颜色值验证(3/6位)
bool IsSafeSqlString(string value) // SQL安全字符串验证
bool IsNormalChar(string value) // 正常字符验证(字母数字下划线)
10. 文件操作和XML处理
图片处理 (ExImage)
// 二进制流保存到文件
// 文件夹清空操作
// 图片无损压缩
// 支持多种图片格式处理
XML项目文件操作
void WriteCsproj(string csprojPath, string filePath, bool isContent)
// csprojPath: 项目文件路径
// filePath: 要包含的文件路径
// isContent: 是否为内容文件
11. HTTP客户端 - 完整功能
HTTP请求配置
string HttpPost(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
// contentType支持:
// - application/xml
// - application/json
// - application/text
// - application/x-www-form-urlencoded
// 头部信息支持自定义
异步HTTP请求
Task<string> HttpPostAsync(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null)
12. 树形结构处理 - 详细API
树节点接口 (ITreeNode)
long GetId() // 获取节点唯一标识
long GetPid() // 获取父节点标识
void SetChildren(IList children) // 设置子节点列表
树构建工具 (TreeBuildUtil<T>)
List<T> Build(List<T> nodes)
// 功能:
// - 自动识别根节点(Pid=0或null)
// - 递归构建层级关系
// - 支持无限级树形结构
// - 适用于菜单、分类、组织架构等场景
13. 控制台输出增强
彩色输出方法
void WriteColorLine(string str, ConsoleColor color) // 基础彩色输出
// 语义化输出扩展
void WriteErrorLine(this string str, ConsoleColor color = ConsoleColor.Red)
void WriteWarningLine(this string str, ConsoleColor color = ConsoleColor.Yellow)
void WriteInfoLine(this string str, ConsoleColor color = ConsoleColor.White)
void WriteSuccessLine(this string str, ConsoleColor color = ConsoleColor.Green)
14. 拼音和本地化处理
汉字拼音处理
string PinYin(string chineseText) // 汉字转拼音首字母
// 示例:"中国" → "zg"
string ResolvePinYinByFile(string text) // 基于文件的拼音解析
多语言支持
- 简体中文处理
- 繁体中文支持
- 粤语方言处理
- 日语字符支持
- 法语特殊字符
- 英语国际化
15. 唯一标识生成
string Unique() // 全局唯一值生成
string CreateNo() // 自动生成编号
// 格式:年月日时分秒+随机数,如:"201008251145409865"
这个组件确实提供了企业级开发所需的几乎所有基础工具功能,涵盖了从数据验证、类型转换到系统监控、网络通信等各个方面。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. 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. |
-
net7.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on RuoVea.ExUtil:
| Package | Downloads |
|---|---|
|
RuoVea.ExSugar
Sqlsugar扩展 快速注入,支持简体中文、繁体中文、粤语、日语、法语、英语.使用方式:service.AddSqlsugar();继承RestFulLog 重写异常日志,操作日志,差异日志 |
|
|
RuoVea.ExFilter
注入 进行全局的异常日志收集、执行操作日志、参数验证,支持简体中文、繁体中文、粤语、日语、法语、英语.services.ExceptionSetup();// 注入 全局错误日志处 services.ExceptionSetup(ExceptionLog actionOptions);// 注入 全局错误日志处 services.ExceptionSetup(builder.Configuration.GetSection("AopOption:ExceptionLog"));// 注入 全局错误日志处 services.RequestActionSetup();// 注入 请求日志拦截 [执行操作日志、参数验证 ] services.RequestActionSetup(RequestLog actionOptions);// 注入 请求日志拦截 [执行操作日志、参数验证 ] services.RequestActionSetup(builder.Configuration.GetSection("AopOption:RequestLog"));// 注入 请求日志拦截 [执行操作日志、参数验证 ] services.ResourceSetup();//对资源型信息进行过滤 services.ResultSetup();//对结果进行统一 services.ApISafeSetup(AppSign actionOptions);//接口安全校验 services.ApISafeSetup(builder.Configuration.GetSection("AopOption:AppSign"));//接口安全校验 services.ApISignSetup(AppSign actionOptions);//签名验证 ( appKey + signKey + timeStamp + data ); services.ApISignSetup(builder.Configuration.GetSection("AopOption:AppSign"));//签名验证 ( appKey + signKey + timeStamp + data ); services.AddValidateSetup();//模型校验 services.AddUiFilesZipSetup();//将前端UI压缩文件进行解压 不进行接口安全校验 -> NonAplSafeAttribute 不签名验证 -> NonAplSignAttribute 不进行全局的异常日志收集 -> NonExceptionAttribute 不对资源型信息进行过滤 -> NonResourceAttribute 不对结果进行统一 -> NonRestfulResultAttribute |
|
|
RuoVea.ExWeb
CorsUrls、IPLimit、SafeIps、Jwt 配置 |
|
|
RuoVea.ExGlobal
web 注入 全局错误日志、操作日志记录 |
|
|
PBKDF2.Key
PBKDF2(Password-Based Key Derivation Function)是一个用来导出密钥的函数,常用于生成加密的密码。它的基本原理是通过一个伪随机函数(例如HMAC函数),把明文和一个盐值作为输入参数,然后重复进行运算,并最终产生密钥。如果重复的次数足够大,破解的成本就会变得很高。而盐值的添加也会增加“彩虹表”攻击的难度。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0.2 | 197 | 1/27/2026 |
| 10.0.0.1 | 104 | 1/26/2026 |
| 10.0.0 | 126 | 1/12/2026 |
| 9.0.0.2 | 274 | 1/27/2026 |
| 9.0.0.1 | 124 | 1/26/2026 |
| 9.0.0 | 617 | 7/25/2025 |
| 8.0.1.3 | 572 | 1/27/2026 |
| 8.0.1.2 | 205 | 1/26/2026 |
| 8.0.1.1 | 7,858 | 10/31/2024 |
| 7.0.1.3 | 644 | 1/27/2026 |
| 7.0.1.2 | 152 | 1/26/2026 |
| 6.0.14.3 | 793 | 1/27/2026 |
| 6.0.14.2 | 139 | 1/26/2026 |
| 5.0.20.3 | 149 | 1/27/2026 |
| 5.0.20.2 | 151 | 1/26/2026 |
| 5.0.20.1 | 712 | 11/1/2024 |
| 2.1.2.4 | 91 | 1/27/2026 |
| 2.1.2.1 | 158 | 11/1/2024 |
| 2.0.0.3 | 88 | 1/27/2026 |
| 2.0.0.1 | 166 | 11/1/2024 |