mirror of
				https://github.com/nsnail/NetAdmin.git
				synced 2025-10-31 11:25:27 +08:00 
			
		
		
		
	style: 💄 代码样式 (#83)
This commit is contained in:
		| @@ -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. | ||||||
|   | |||||||
| @@ -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}"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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) { | ||||||
|   | |||||||
| @@ -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 ?? | ||||||
|   | |||||||
| @@ -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> | ||||||
|     ///     创建一个缺口滑块验证码图片 |     ///     创建一个缺口滑块验证码图片 | ||||||
|   | |||||||
| @@ -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]); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 GitHub
						GitHub