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

@ -5,15 +5,15 @@ namespace NetAdmin.Domain.Dto.Sys.Cache;
/// </summary> /// </summary>
public sealed record CacheStatisticsRsp : DataAbstraction public sealed record CacheStatisticsRsp : DataAbstraction
{ {
private static readonly Regex[] _regexes = { private static readonly Regex[] _regexes = [
new(@"keyspace_hits:(\d+)", RegexOptions.Compiled) new Regex(@"keyspace_hits:(\d+)", RegexOptions.Compiled) //
, new(@"keyspace_misses:(\d+)", RegexOptions.Compiled) , new Regex(@"keyspace_misses:(\d+)", RegexOptions.Compiled) //
, new(@"uptime_in_seconds:(\d+)", RegexOptions.Compiled) , new Regex(@"uptime_in_seconds:(\d+)", RegexOptions.Compiled) //
, new(@"used_cpu_sys:([\d\\.]+)", RegexOptions.Compiled) , new Regex(@"used_cpu_sys:([\d\\.]+)", RegexOptions.Compiled) //
, new(@"used_cpu_user:([\d\\.]+)", RegexOptions.Compiled) , new Regex(@"used_cpu_user:([\d\\.]+)", RegexOptions.Compiled) //
, new(@"used_memory:(\d+)", RegexOptions.Compiled) , new Regex(@"used_memory:(\d+)", RegexOptions.Compiled) //
, new("redis_version:(.+)", RegexOptions.Compiled) , new Regex("redis_version:(.+)", RegexOptions.Compiled) //
}; ];
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CacheStatisticsRsp" /> class. /// 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) { foreach (var type in optionsTypes) {
var configureMethod = typeof(ConfigurableOptionsServiceCollectionExtensions).GetMethod( var configureMethod = typeof(ConfigurableOptionsServiceCollectionExtensions).GetMethod(
nameof(ConfigurableOptionsServiceCollectionExtensions.AddConfigurableOptions) nameof(ConfigurableOptionsServiceCollectionExtensions.AddConfigurableOptions)
, BindingFlags.Public | BindingFlags.Static, new[] { typeof(IServiceCollection) }); , BindingFlags.Public | BindingFlags.Static, [typeof(IServiceCollection)]);
_ = configureMethod!.MakeGenericMethod(type).Invoke(me, new object[] { me }); _ = configureMethod!.MakeGenericMethod(type).Invoke(me, [me]);
_ = sbLog.Append(CultureInfo.InvariantCulture, $" {type.Name}"); _ = sbLog.Append(CultureInfo.InvariantCulture, $" {type.Name}");
} }

View File

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

View File

@ -12,7 +12,7 @@ public sealed class RequestLogger(
, IOptions<SpecificationDocumentSettingsOptions> specificationDocumentSettingsOptions , IOptions<SpecificationDocumentSettingsOptions> specificationDocumentSettingsOptions
, IEventPublisher eventPublisher) : ISingleton , 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 private readonly int _tokenPrefixLength
= specificationDocumentSettingsOptions?.Value.SecurityDefinitions?[0]?.Scheme?.Length + 1 ?? = specificationDocumentSettingsOptions?.Value.SecurityDefinitions?[0]?.Scheme?.Length + 1 ??

View File

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

View File

@ -50,10 +50,12 @@ public sealed class FreeSqlBuilder(DatabaseOptions databaseOptions)
{ {
return typeof(IBaseRepository<>).MakeGenericType(entityType) return typeof(IBaseRepository<>).MakeGenericType(entityType)
.GetMethod( // .GetMethod( //
nameof(IBaseRepository<dynamic>.Insert) nameof(IBaseRepository<dynamic>.Insert) //
, BindingFlags.Public | BindingFlags.Instance, null , BindingFlags.Public | BindingFlags.Instance //
, CallingConventions.Any , null //
, new[] { typeof(IEnumerable<>).MakeGenericType(entityType) }, null); , CallingConventions.Any //
, [typeof(IEnumerable<>).MakeGenericType(entityType)] //
, null);
} }
/// <summary> /// <summary>
@ -108,7 +110,7 @@ public sealed class FreeSqlBuilder(DatabaseOptions databaseOptions)
continue; 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) { if (rep?.GetType().GetProperty(nameof(DbContextOptions))?.GetValue(rep) is DbContextOptions options) {
options.EnableCascadeSave = true; options.EnableCascadeSave = true;
options.NoneParameter = true; options.NoneParameter = true;
@ -116,7 +118,7 @@ public sealed class FreeSqlBuilder(DatabaseOptions databaseOptions)
var insert = MakeInsertMethod(entityType); 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) // public sealed class VerifyCodeService(DefaultRepository<Sys_VerifyCode> rpo, IEventPublisher eventPublisher) //
: RepositoryService<Sys_VerifyCode, IVerifyCodeService>(rpo), IVerifyCodeService : RepositoryService<Sys_VerifyCode, IVerifyCodeService>(rpo), IVerifyCodeService
{ {
private static readonly int[] _randRange = { 0, 10000 }; private static readonly int[] _randRange = [0, 10000];
/// <inheritdoc /> /// <inheritdoc />
public async Task<int> BulkDeleteAsync(BulkReq<DelReq> req) public async Task<int> BulkDeleteAsync(BulkReq<DelReq> req)