![]() |
VOOZH | about |
dotnet add package VinBen.Tool --version 0.0.1.7
NuGet\Install-Package VinBen.Tool -Version 0.0.1.7
<PackageReference Include="VinBen.Tool" Version="0.0.1.7" />
<PackageVersion Include="VinBen.Tool" Version="0.0.1.7" />Directory.Packages.props
<PackageReference Include="VinBen.Tool" />Project file
paket add VinBen.Tool --version 0.0.1.7
#r "nuget: VinBen.Tool, 0.0.1.7"
#:package VinBen.Tool@0.0.1.7
#addin nuget:?package=VinBen.Tool&version=0.0.1.7Install as a Cake Addin
#tool nuget:?package=VinBen.Tool&version=0.0.1.7Install as a Cake Tool
Vin.Tool 是 Vin.AspNetCore.Core 的工具类库,包含了一些常用的工具类。
暂不支持单文件发布,需要引用源码。参考地址:参考地址
appsettings.json 中配置 IpAuth 节点,配置后仅在范围的IP可以访问改Action,配置方式如下:{
"Vin": {
"IpAuth": {
// 选其中一个使用
// 白名单
"WhiteList": [],
// 黑名单
"BlackList": []
}
}
}
[Inject] 可选参数
1. Key:指定服务的Key
[Service] 可选参数
1. Lifetime:生命周期 Transient、Scoped、Singleton
2. InterfaceType:服务实现的接口
3. InterfaceTypes:服务实现的多个接口
4. Key:指定服务的Key
5. Order:指定服务的注入顺序
[Inject] 可选参数
1. Key:指定配置的路径
IgnoreServiceAttribute: 一个忽略服务注入特性,用于标记不需要注入的服务.
ModelAttribute: 一个模型特性,用于标记模型的属性.
[ClearValue] 可选参数
1. ContainsFields:当前类包含某些字段时,清空当前值
[StringArray] 可选参数
1. Separator:分隔符,默认为英文逗号 ","
ApplicationStartedEventArg: 应用启动事件参数
ApplicationStoppedEventArg: 应用停止事件参数
ApplicationStoppingEventArg: 应用停止中事件参数
VinEventManager.Register<ApplicationStoppingEventArg>((obj, e) => { });
// 属性
ServiceProvider:获取服务的提供者
MvcBuilder:获取MvcBuilder
WebApplication:获取Web应用程序
Configuration:获取配置
WebHostEnvironment:获取Web主机环境
VinInitBuilderConfig:获取初始Builder配置
VinUseApplicationConfig:获取使用Application配置
ApiResultType:获取Api响应类型
HttpContextAccessor:获取HttpContext访问器
AsyncServiceProvider:获取异步服务提供者
HttpContext:获取HttpContext
HttpContextOrNull: 获取HttpContext或者null
HaveHttpContext:是否有HttpContext
User:获取请求上下文用户
// 静态方法
SetServiceProvider:设置服务提供者
SetMvcBuilder:设置MvcBuilder
SetWebApplication:设置Web应用程序
SetConfiguration:设置配置
SetWebHostEnvironment:设置Web主机环境
SetVinInitBuilderConfig:设置初始Builder配置
SetVinUseApplicationConfig:设置使用Application配置
SetApiResultType:设置Api响应类型
HttpContextInfo:获取HttpContext信息 parseClient:是否解析客户端信息(user-agent)
SimulateHttpContext:模拟HttpContext
CreateScopeAsync:创建作用域
GetService:获取服务 serviceKey:服务Key(可选)
GetServices:获取服务
GetKeyService:获取服务
GetRequiredService:获取服务
GetRequestServiceProvider:获取请求服务提供者
GetServiceByHttpContext:获取服务
GetRequiredKeyServiceByHttpContext:获取服务
.....
AddInjectProvider:添加注入提供者
Inject:增加注入服务,不然当前类使用[Inject]特性无效
GetLogger:获取日志
GetConfig:获取配置
GetOptionsMonitor:获取配置
// 属性
GetProjectAssemblies:获取项目程序集
GetProjectTypes:获取GetProjectAssemblies中所有类型
GetVinAssemblies:获取Vin程序集(程序集为"Vin.","VinBen."和VinInitBuilderConfig.AssemblyNames中配置的程序集)
GetVinTypes:获取GetVinAssemblies中所有类型
// 静态方法
GetAssemblies:获取指定内容的程序集
GetAssemblies:获取包含指定名称的程序集
GetTypes:获取包含指定类型的类型
GetCallingAssembly:获取入口程序集
GetAssemblyName:获取程序集名称
GetManifestResourceNames:获取程序集资源名称
GetManifestResourceStreamAsync:获取程序集资源流
GetManifestResourceString:获取程序集资源字符串
GetManifestResourceStringAsync:获取程序集资源字符串
GetManifestResourceInfo:获取程序集资源信息
// 静态方法
CheckIsNullOrEmpty:检查是否为空或者null,并抛出异常
CheckIsNullOrZero:检查是否为空或者null或者0,并抛出异常
CheckIsNull:检查是否为空,并抛出异常
// 字符串可用扩展
IsNullOrEmpty
IsNull
IsNotNullOrEmpty
IsNotNull
IsNullOrWhiteSpace
IsNotNullOrWhiteSpace
// 静态方法
IsMobile:是否手机号码
IsEmail:是否邮箱
// 字符串可用扩展
IsMobile
IsEmail
// 静态方法
TryOnlyValidateObject:只验证对象是否符合规则 obj:对象,validateAllProperties:是否验证所有属性(true),throwException:是否抛出异常(true)
TryValidateObject:验证对象是否符合规则
// 泛型扩展方法
IsValidateObject:验证对象是否符合规则
// object 扩展方法
IsValueType: 是否值类型
IsEnum: 是否枚举
// long 扩展方法
ToDateTime: 时间戳转日期 isMilliseconds:是否毫秒(true)
// string 扩展方法
ToUnderLine: 转下划线 isToUpper:是否大写(false)
ToMiddleLine: 转中划线 isToUpper:是否大写(false)
ToCamelCase: 转驼峰 isToUpper:首字母是否大写(false)
LatterString:从字符串的末尾获取指定长度的字符串
Format: 格式化字符串
IsBase64: 是否Base64字符串
IsBase64ByTry: 是否Base64字符串
ToDateTime: 字符串转日期
IfNull:如果为空返回默认值
// Enum 扩展方法
GetData:获取数据(值,名称)
GetName:获取名称
GetCustomAttribute:获取自定义特性(每个值上)
GetCustomEnumAttribute:获取自定义特性(枚举类上)
GetEnumMemberValue:获取EnumMemberAttribute的值
// 静态方法
ExceptionMessage:获取异常消息
// 扩展方法
ExceptionMessage:获取异常消息
// 静态方法
CalculateDistance:计算两点之间的距离
// 静态方法,扩展方法
IsNullOrZero:是否为空或者0
// 属性
DefaultOptions:默认配置
CamelCaseOptions:小驼峰配置
UnderLineLowerOptions:下划线小写配置
UnderLineUpperOptions:下划线大写配置
MiddleLineLowerOptions:中划线小写配置
MiddleLineUpperOptions:中划线大写配置
// 静态方法
GenerateJsonOptions:生成Json配置
// 扩展方法
ToJsonElement:json转JsonElement
ToObject:json转对象
ToJson:对象转json
ToCamelCaseObject:对象转驼峰json(小)
ToCamelCaseJson:对象转驼峰json(小)
ToUnderLineObject:对象转下划线json(小)
ToUnderLineJson:对象转下划线json(小)
ToMiddleLineObject:对象转中划线json(小)
ToMiddleLineJson:对象转中划线json(小)
// JsonConverter
DateConverter:日期转换器
DateTimeConverter:日期时间转换器
DateTimeNullConverter:日期时间转换器
EnumToStringConverter:枚举转字符串转换器
LongTimeToStringConverter:长整型时间转字符串转换器
LongToStringConverter:长整型转字符串转换器
ObjectToJsonStringConverter:对象转json字符串转换器
// 静态方法
IsIp: 是否IP
ToCurl: 转Curl
ParserUserAgent: 解析UserAgent
// 扩展方法
GetClientUserIp: 获取客户端IP
GetClientInfo: 获取客户端信息
GetClientDetail:获取客户端详细信息
ReadToString:读取Body字符串
ReadToJson:读取Body对象(JsonElement)
ToCurl:转Curl
SetItems:设置HttpContext.Items
GetItems:获取HttpContext.Items
GenerateRequestId:生成RequestId
GetRequestId:获取RequestId
// 静态方法
DirPathCheck:目录路径检查
ExtensionCheck:扩展名检查 (判断是否是.xxx格式)
// 静态方法
RandomInt:随机整数
RandomDouble:随机小数
RandomLong:随机长整型
RandomString:随机字符串
RandomLetter:随机字母
RandomNumber:随机数字
// 静态方法
RandomColor:随机颜色
// 静态方法,扩展方法
ReadToString:读取流到字符串
ReadToJson:读取流到JsonElement
| 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 is compatible. 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. |
Showing the top 5 NuGet packages that depend on VinBen.Tool:
| Package | Downloads |
|---|---|
|
VinBen.AspNetCore.Core
Vin Core |
|
|
VinBen.Extension.Cache
Package Description |
|
|
VinBen.Extension.Aop
Package Description |
|
|
VinBen.Extension.SqlSugar
Package Description |
|
|
VinBen.Extension.Exception
Package Description |
This package is not used by any popular GitHub repositories.