mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-04-20 05:02:50 +08:00
style: 💄 代码样式 (#83)
This commit is contained in:
parent
9a8b159c81
commit
35411b8c38
@ -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) |
|
@ -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.
|
||||
|
@ -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}");
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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 ??
|
||||
|
@ -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>
|
||||
/// 创建一个缺口滑块验证码图片
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user