AzrngCommon.Core 1.3.0

dotnet add package AzrngCommon.Core --version 1.3.0                
NuGet\Install-Package AzrngCommon.Core -Version 1.3.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="AzrngCommon.Core" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AzrngCommon.Core --version 1.3.0                
#r "nuget: AzrngCommon.Core, 1.3.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.
// Install AzrngCommon.Core as a Cake Addin
#addin nuget:?package=AzrngCommon.Core&version=1.3.0

// Install AzrngCommon.Core as a Cake Tool
#tool nuget:?package=AzrngCommon.Core&version=1.3.0                

Common.Core

一个公共的帮助类库,包含一些常用通用的方法。

下面的文档还没补充完整,待完善

扩展类

StringExtension
//判断字符串是否是数值类型
bool IsIntFormat(this string str)
// 判断字符串是否是decimal类型
bool IsDecimalFormat(this string str)
//判断字符串是否是日期类型
bool IsDateFormat(this string str)
//判断字符串是否包含中文
bool HasChinese(this string str)
//判断字符串不是  null、空和空白字符
bool IsNotNullOrWhiteSpace(this string currentString)
//判断字符串 是  null、空和空白字符
bool IsNullOrWhiteSpace(this string currentString)
//判断字符串是  null、空
bool IsNullOrEmpty(this string currentString)
//判断字符串不是  null、空
bool IsNotNullOrEmpty(this string currentString)
//字符串分割成字符串数组
string[] ToStrArray(this string str, string separator = ",")
//根据条件拼接字符串
StringBuilder AppendIF(this StringBuilder builder, bool condition, string str)
//获取特定位置的字符串
string GetByIndex(this string str, int index)
//忽略大小写的字符串比较
bool EqualsNoCase(this string aimStr, string comparaStr)
ObjectExtensions

模型类转url参数格式(1.0.5)

var userInfo = new UserInfoDto { Id = 1, Name = "Test", };
// 参数不转小写
var result = userInfo.ToUrlParameter();// Id=1&Name=Test
// 参数转小写
var result = userInfo.ToUrlParameter(true);// id=1&name=Test

帮助类

LocalLogHelper

支持异步写入日志、支持历史日志清理(默认7天)、支持设置是否输出指定等级的日志

// 异步记录日志
await LocalLogHelper.WriteMyLogsAsync("Info", "这是一条测试日志");

// 或继续使用现有的同步方法
LocalLogHelper.LogInformation("这是一条信息日志");

// 如果想设置只输出指定等级以上的日志,可以进行如下设置
GlobalConfig.MinimumLevel = LogLevel.Warning;
// 再次之后输出输出的日志就只会输出警告及以上的日志

公共返回类

封装了公共的返回类

IResultModel
IResultModel<T>
ResultModel:IsSuccess、Code、Message、Errors
ResultModel<T>:IsSuccess、Code、Message、Data

属性描述

IsSuccess:是否成功 Code:状态码 Data:返回的数据 Errors:模型校验的错误信息

返回正确的方法

[HttpGet]
public IResultModel<IEnumerable<WeatherForecast>> Get()
{
    var result = Enumerable.Range(1, 3).Select(index => new WeatherForecast
    {
        Date = DateTime.Now.AddDays(index),
        TemperatureC = Random.Shared.Next(-20, 55),
        Summary = Summaries[Random.Shared.Next(Summaries.Length)]
    })
    .ToArray();
    return ResultModel<IEnumerable<WeatherForecast>>.Success(result);
}

返回的示例效果

{
  "data": [
    {
      "date": "2022-05-20T22:13:35.2501522+08:00",
      "temperatureC": 52,
      "temperatureF": 125,
      "summary": "Freezing"
    },
    {
      "date": "2022-05-21T22:13:35.2505438+08:00",
      "temperatureC": 4,
      "temperatureF": 39,
      "summary": "Balmy"
    },
    {
      "date": "2022-05-24T22:13:35.250546+08:00",
      "temperatureC": 7,
      "temperatureF": 44,
      "summary": "Hot"
    }
  ],
  "isSuccess": true,
  "code": "200",
  "message": "success",
  "errors": []
}

返回错误的效果

[HttpGet]
public IResultModel<IEnumerable<WeatherForecast>> Get()
{
    return ResultModel<IEnumerable<WeatherForecast>>.Error("参数为空", "400");
}

返回结果

{
  "data": null,
  "isSuccess": false,
  "code": "400",
  "message": "参数为空",
  "errors": []
}

版本更新记录

  • 1.3.0
    • 更新List转DataTable操作
    • 优化本地日志写法,支持异步处理
  • 1.2.1
    • 增加排序url参数值 UriHelper.SortUrlParameters,调整url扩展方法和帮助类
    • 日志帮助类增加修改日志输出的级别
    • 日志帮助类增加超过7天自动删除
    • 增加IJsonSerializer接口
    • 增加sql安全检测帮助类
    • 在HtmlHelper下增加HtmlToText
    • DateTimeHelper下增加GetTimeDifferenceText
    • 增加CsvHelper
    • 调整部分扩展方法目录
  • 1.2.0
    • 移除包Newtonsoft.Json的依赖
    • 更新获取网络时间的接口API
    • 禁用部分涉及到序列化的方法
  • 1.1.6
    • 修复GetColumnValueByName方法bug
    • 支持.Net9
  • 1.1.5
    • 修改GetColumnValueByName方法bug
  • 1.1.4
    • 增加IEnumerable的WithIndex扩展
    • ApplicationHelper类增加RuntimeInfo方法
    • 优化IO操作方法
  • 1.1.3
    • 字典增加GetOrDefault扩展方法
    • 调整Guard中message和参数的顺序
  • 1.1.2
    • 更新时间扩展,增加 DateTime?.ToDateString、DateTime?.ToStandardString
    • 将一部分方法抽离到DateTimeHelper中,防止扩展污染
    • 修改where筛选QueryableWhereIF为QueryableWhereIf
  • 1.1.1
    • 增加默认无参数的ToStandardString
    • 增加将时间转年月日:ToDateString
    • 增加Guard帮助类,使用方法比如Guard.Against.Null("输入值", "参数名");
    • 增加Console的输出ReadLineWithPrompt、ReadKeyWithPrompt
    • 增加ApplicationHelper应用程序帮助类
    • 将LongHelper改名为NumberHelper
    • 增加获取无时区的当前时间
  • 1.1.0
    • 优化ResultModel类,增加Failure方法
  • 1.0.10
    • 增加AsyncHelper执行同步方法
    • 移除获取时间戳弃用的方法
    • 增加CollectionHelper支持分页批次处理数据
    • 增加FileHelper.FormatFileSize
  • 1.0.9
    • 获取特殊文件夹之桌面文件路径
    • 增加检查文件是否被其他进程锁定方法
    • 增加获取NTP网络远程时间
    • 增加系统操作:获取本机ip、ipv4地址、ipv6地址
    • 增加MimeExtensions扩展
  • 1.0.8
    • 升级支持.net8
  • 1.0.7
    • 更新ICurrentUser默认为string类型UserId
  • 1.0.6
    • 增加程序集扩展方法和程序集帮助类以及获取所有程序集的方法
    • 增加枚举帮助类EnumHelper,迁移枚举扩展中部分方法到枚举帮助类中
    • 枚举扩展类中方法GetDescriptionString改名GetDescription
  • 1.0.5
    • 增加Random的NextDouble扩展方法
    • 支持框架net6.0;net7.0
  • 1.0.4
    • 迁移base64的扩展到StringExtension,并且改名为ToBase64Encode、FromBase64Decode
    • 增加时间段和时间点相互转换代码
    • 增加ExceptionExtension、DecimalExtension、DoublelExtension
  • 1.0.3
    • 增加任务运行时间限制方法,TaskHelper.RunTimeLimitAsync

    • 增加字符串输出扩展

  • 1.0.2
    • 增加本地日志文件操作类
  • 1.0.1
    • 引用Newtonsoft.Json包,增加json操作扩展
    • 将扩展方法的命名空间改为Common.Extension
  • 1.0.0
    • 将common中的部分类移动到该类库中
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 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 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 is compatible.  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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on AzrngCommon.Core:

Package Downloads
AzrngCommon

基本的公共类库

Common.JwtToken

一个jwt简单封装的类库

Common.Mvc

基本的公共类库

SettingConfig

该项目是一个业务配置维护的Nuget包

Azrng.AspNetCore.Authentication.Basic

基础的Basic认证包

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 48 2/20/2025
1.2.1 174 12/23/2024
1.2.0 144 11/28/2024
1.1.6 105 11/17/2024
1.1.5 95 11/16/2024
1.1.4 134 10/20/2024
1.1.3 326 9/15/2024
1.1.2 244 8/22/2024
1.1.1 151 8/9/2024
1.1.0 153 7/22/2024
1.0.10 139 6/26/2024
1.0.9 177 4/11/2024
1.0.8 469 11/15/2023
1.0.7 157 10/21/2023
1.0.6 159 10/21/2023
1.0.5 205 10/6/2023
1.0.4 197 8/10/2023
1.0.3 166 6/4/2023
1.0.2 195 4/22/2023
1.0.1 424 3/18/2023
1.0.0 357 2/1/2023