style: 💄 代码样式 (#83)

This commit is contained in:
nsnail 2024-01-23 10:50:26 +08:00 committed by GitHub
parent 9a8b159c81
commit 35411b8c38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 25 additions and 23 deletions

View File

@ -127,4 +127,4 @@ XC-->XA
| JavaScript | JavaScript解析器 | [Terser](https://github.com/terser/terser) |
| JavaScript | 代码质量检查 | [ESLint](https://github.com/eslint/eslint) |
| JavaScript | 代码格式化工具 | [Prettier](https://github.com/prettier/prettier) |
| JavaScript | 标准加密库 | [crypto-js](https://github.com/brix/crypto-js) |
| JavaScript | 标准加密库 | [crypto-js](https://github.com/brix/crypto-js) |

View File

@ -5,15 +5,15 @@ namespace NetAdmin.Domain.Dto.Sys.Cache;
/// </summary>
public sealed record CacheStatisticsRsp : DataAbstraction
{
private static readonly Regex[] _regexes = {
new(@"keyspace_hits:(\d+)", RegexOptions.Compiled)
, new(@"keyspace_misses:(\d+)", RegexOptions.Compiled)
, new(@"uptime_in_seconds:(\d+)", RegexOptions.Compiled)
, new(@"used_cpu_sys:([\d\\.]+)", RegexOptions.Compiled)
, new(@"used_cpu_user:([\d\\.]+)", RegexOptions.Compiled)
, new(@"used_memory:(\d+)", RegexOptions.Compiled)
, new("redis_version:(.+)", RegexOptions.Compiled)
};
private static readonly Regex[] _regexes = [
new Regex(@"keyspace_hits:(\d+)", RegexOptions.Compiled) //
, new Regex(@"keyspace_misses:(\d+)", RegexOptions.Compiled) //
, new Regex(@"uptime_in_seconds:(\d+)", RegexOptions.Compiled) //
, new Regex(@"used_cpu_sys:([\d\\.]+)", RegexOptions.Compiled) //
, new Regex(@"used_cpu_user:([\d\\.]+)", RegexOptions.Compiled) //
, new Regex(@"used_memory:(\d+)", RegexOptions.Compiled) //
, new Regex("redis_version:(.+)", RegexOptions.Compiled) //
];
/// <summary>
/// Initializes a new instance of the <see cref="CacheStatisticsRsp" /> class.

View File

@ -90,8 +90,8 @@ public static class ServiceCollectionExtensions
foreach (var type in optionsTypes) {
var configureMethod = typeof(ConfigurableOptionsServiceCollectionExtensions).GetMethod(
nameof(ConfigurableOptionsServiceCollectionExtensions.AddConfigurableOptions)
, BindingFlags.Public | BindingFlags.Static, new[] { typeof(IServiceCollection) });
_ = configureMethod!.MakeGenericMethod(type).Invoke(me, new object[] { me });
, BindingFlags.Public | BindingFlags.Static, [typeof(IServiceCollection)]);
_ = configureMethod!.MakeGenericMethod(type).Invoke(me, [me]);
_ = sbLog.Append(CultureInfo.InvariantCulture, $" {type.Name}");
}

View File

@ -75,7 +75,7 @@ public abstract class ApiResultHandler<T>
? dic.ToDictionary( //
x => (startWithDollar = x.Key.StartsWith('$'))
? x.Key[1..].TrimStart('.').NullOrEmpty(null) ?? throw new NetAdminInvalidInputException()
: x.Key, x => startWithDollar ? new[] { Ln. } : x.Value)
: x.Key, x => startWithDollar ? [Ln.] : x.Value)
: validationResult;
}
catch (NetAdminInvalidInputException) {

View File

@ -12,7 +12,7 @@ public sealed class RequestLogger(
, IOptions<SpecificationDocumentSettingsOptions> specificationDocumentSettingsOptions
, IEventPublisher eventPublisher) : ISingleton
{
private static readonly string[] _textContentTypes = { "text", "json", "xml", "urlencoded" };
private static readonly string[] _textContentTypes = ["text", "json", "xml", "urlencoded"];
private readonly int _tokenPrefixLength
= specificationDocumentSettingsOptions?.Value.SecurityDefinitions?[0]?.Scheme?.Length + 1 ??

View File

@ -12,7 +12,7 @@ namespace NetAdmin.Infrastructure.Utils;
/// </summary>
public static class CaptchaImageHelper
{
private static readonly int[] _randRange = { 70, 100 };
private static readonly int[] _randRange = [70, 100];
/// <summary>
/// 创建一个缺口滑块验证码图片

View File

@ -49,11 +49,13 @@ public sealed class FreeSqlBuilder(DatabaseOptions databaseOptions)
private static MethodInfo MakeInsertMethod(Type entityType)
{
return typeof(IBaseRepository<>).MakeGenericType(entityType)
.GetMethod( //
nameof(IBaseRepository<dynamic>.Insert)
, BindingFlags.Public | BindingFlags.Instance, null
, CallingConventions.Any
, new[] { typeof(IEnumerable<>).MakeGenericType(entityType) }, null);
.GetMethod( //
nameof(IBaseRepository<dynamic>.Insert) //
, BindingFlags.Public | BindingFlags.Instance //
, null //
, CallingConventions.Any //
, [typeof(IEnumerable<>).MakeGenericType(entityType)] //
, null);
}
/// <summary>
@ -108,7 +110,7 @@ public sealed class FreeSqlBuilder(DatabaseOptions databaseOptions)
continue;
}
var rep = MakeGetRepositoryMethod(entityType)?.Invoke(null, new object[] { freeSql, null });
var rep = MakeGetRepositoryMethod(entityType)?.Invoke(null, [freeSql, null]);
if (rep?.GetType().GetProperty(nameof(DbContextOptions))?.GetValue(rep) is DbContextOptions options) {
options.EnableCascadeSave = true;
options.NoneParameter = true;
@ -116,7 +118,7 @@ public sealed class FreeSqlBuilder(DatabaseOptions databaseOptions)
var insert = MakeInsertMethod(entityType);
_ = insert?.Invoke(rep, new[] { entities });
_ = insert?.Invoke(rep, [entities]);
}
}

View File

@ -14,7 +14,7 @@ namespace NetAdmin.SysComponent.Application.Services.Sys;
public sealed class VerifyCodeService(DefaultRepository<Sys_VerifyCode> rpo, IEventPublisher eventPublisher) //
: RepositoryService<Sys_VerifyCode, IVerifyCodeService>(rpo), IVerifyCodeService
{
private static readonly int[] _randRange = { 0, 10000 };
private static readonly int[] _randRange = [0, 10000];
/// <inheritdoc />
public async Task<int> BulkDeleteAsync(BulkReq<DelReq> req)