diff --git a/Blog.Core.Api/Controllers/DbFirst/DbFirstController.cs b/Blog.Core.Api/Controllers/DbFirst/DbFirstController.cs index 31e7bf5..4f51856 100644 --- a/Blog.Core.Api/Controllers/DbFirst/DbFirstController.cs +++ b/Blog.Core.Api/Controllers/DbFirst/DbFirstController.cs @@ -36,7 +36,7 @@ namespace Blog.Core.Controllers { var data = new MessageModel() { success = true, msg = "" }; data.response += @"file path is:C:\my-file\}"; - var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); + var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); if (Env.IsDevelopment()) { data.response += $"Controller层生成:{FrameSeed.CreateControllers(_sqlSugarClient)} || "; @@ -74,7 +74,7 @@ namespace Blog.Core.Controllers { ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID; - var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); + var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); var data = new MessageModel() { success = true, msg = "" }; if (Env.IsDevelopment()) { @@ -102,7 +102,7 @@ namespace Blog.Core.Controllers { ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID; - var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); + var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); var data = new MessageModel() { success = true, msg = "" }; if (Env.IsDevelopment()) { @@ -126,7 +126,7 @@ namespace Blog.Core.Controllers { ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID; - var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); + var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); var data = new MessageModel() { success = true, msg = "" }; if (Env.IsDevelopment()) { @@ -151,7 +151,7 @@ namespace Blog.Core.Controllers { ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID; - var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); + var isMuti = AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); var data = new MessageModel() { success = true, msg = "" }; if (Env.IsDevelopment()) { diff --git a/Blog.Core.Api/Controllers/MonitorController.cs b/Blog.Core.Api/Controllers/MonitorController.cs index 1ad278a..c0dbed5 100644 --- a/Blog.Core.Api/Controllers/MonitorController.cs +++ b/Blog.Core.Api/Controllers/MonitorController.cs @@ -69,7 +69,7 @@ namespace Blog.Core.Controllers [HttpGet] public MessageModel> Get() { - if (Appsettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool()) { _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait(); } @@ -226,7 +226,7 @@ namespace Blog.Core.Controllers { List apiDates = new List(); - if (Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) { var users = await _applicationUserServices.Query(d => d.tdIsDelete == false); diff --git a/Blog.Core.Api/Controllers/ValuesController.cs b/Blog.Core.Api/Controllers/ValuesController.cs index f1e12ee..52eb0ea 100644 --- a/Blog.Core.Api/Controllers/ValuesController.cs +++ b/Blog.Core.Api/Controllers/ValuesController.cs @@ -392,7 +392,7 @@ namespace Blog.Core.Controllers [AllowAnonymous] public async Task GetConfigByAppllo(string key) { - return await Task.FromResult(Appsettings.app(key)); + return await Task.FromResult(AppSettings.app(key)); } #endregion diff --git a/Blog.Core.Api/Filter/GlobalExceptionFilter.cs b/Blog.Core.Api/Filter/GlobalExceptionFilter.cs index 9abd32f..da119a6 100644 --- a/Blog.Core.Api/Filter/GlobalExceptionFilter.cs +++ b/Blog.Core.Api/Filter/GlobalExceptionFilter.cs @@ -56,7 +56,7 @@ namespace Blog.Core.Filter //采用log4net 进行错误日志记录 _loggerHelper.LogError(json.msg + WriteLog(json.msg, context.Exception)); - if (Appsettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool()) { _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait(); } diff --git a/Blog.Core.Api/Program.cs b/Blog.Core.Api/Program.cs index 41ec3ef..b3bf238 100644 --- a/Blog.Core.Api/Program.cs +++ b/Blog.Core.Api/Program.cs @@ -51,12 +51,12 @@ builder.Host // 2、配置服务 -builder.Services.AddSingleton(new Appsettings(builder.Configuration)); +builder.Services.AddSingleton(new AppSettings(builder.Configuration)); builder.Services.AddSingleton(new LogLock(builder.Environment.ContentRootPath)); builder.Services.AddUiFilesZipSetup(builder.Environment); -Permissions.IsUseIds4 = Appsettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool(); -RoutePrefix.Name = Appsettings.app(new string[] { "AppSettings", "SvcName" }).ObjToString(); +Permissions.IsUseIds4 = AppSettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool(); +RoutePrefix.Name = AppSettings.app(new string[] { "AppSettings", "SvcName" }).ObjToString(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); @@ -151,7 +151,7 @@ app.UseSession(); app.UseSwaggerAuthorized(); app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("Blog.Core.Api.index.html")); -app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" })); +app.UseCors(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" })); DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions(); defaultFilesOptions.DefaultFileNames.Clear(); defaultFilesOptions.DefaultFileNames.Add("index.html"); diff --git a/Blog.Core.Api/Startup.cs b/Blog.Core.Api/Startup.cs index ea81568..b341819 100644 --- a/Blog.Core.Api/Startup.cs +++ b/Blog.Core.Api/Startup.cs @@ -44,12 +44,12 @@ namespace Blog.Core public void ConfigureServices(IServiceCollection services) { // 以下code可能与文章中不一样,对代码做了封装,具体查看右侧 Extensions 文件夹. - services.AddSingleton(new Appsettings(Configuration)); + services.AddSingleton(new AppSettings(Configuration)); services.AddSingleton(new LogLock(Env.ContentRootPath)); services.AddUiFilesZipSetup(Env); - Permissions.IsUseIds4 = Appsettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool(); - RoutePrefix.Name = Appsettings.app(new string[] { "AppSettings", "SvcName" }).ObjToString(); + Permissions.IsUseIds4 = AppSettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool(); + RoutePrefix.Name = AppSettings.app(new string[] { "AppSettings", "SvcName" }).ObjToString(); // 确保从认证中心返回的ClaimType不被更改,不使用Map映射 JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); @@ -182,7 +182,7 @@ namespace Blog.Core // ↓↓↓↓↓↓ 注意下边这些中间件的顺序,很重要 ↓↓↓↓↓↓ // CORS跨域 - app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" })); + app.UseCors(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" })); // 跳转https //app.UseHttpsRedirection(); // 使用静态文件 diff --git a/Blog.Core.Common/DB/AppSecretConfig.cs b/Blog.Core.Common/DB/AppSecretConfig.cs index 8bac10c..befbc8a 100644 --- a/Blog.Core.Common/DB/AppSecretConfig.cs +++ b/Blog.Core.Common/DB/AppSecretConfig.cs @@ -4,8 +4,8 @@ namespace Blog.Core.Common.AppConfig { public class AppSecretConfig { - private static string Audience_Secret = Appsettings.app(new string[] { "Audience", "Secret" }); - private static string Audience_Secret_File = Appsettings.app(new string[] { "Audience", "SecretFile" }); + private static string Audience_Secret = AppSettings.app(new string[] { "Audience", "Secret" }); + private static string Audience_Secret_File = AppSettings.app(new string[] { "Audience", "SecretFile" }); public static string Audience_Secret_String => InitAudience_Secret(); diff --git a/Blog.Core.Common/DB/BaseDBConfig.cs b/Blog.Core.Common/DB/BaseDBConfig.cs index 5972409..dc7fee4 100644 --- a/Blog.Core.Common/DB/BaseDBConfig.cs +++ b/Blog.Core.Common/DB/BaseDBConfig.cs @@ -31,7 +31,7 @@ namespace Blog.Core.Common.DB public static (List, List) MutiInitConn() { - List listdatabase = Appsettings.app("DBS") + List listdatabase = AppSettings.app("DBS") .Where(i => i.Enabled).ToList(); foreach (var i in listdatabase) { @@ -41,7 +41,7 @@ namespace Blog.Core.Common.DB List listdatabaseSlaveDB = new List();//从库 // 单库,且不开启读写分离,只保留一个 - if (!Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) { if (listdatabase.Count == 1) { @@ -49,7 +49,7 @@ namespace Blog.Core.Common.DB } else { - var dbFirst = listdatabase.FirstOrDefault(d => d.ConnId == Appsettings.app(new string[] { "MainDB" }).ObjToString()); + var dbFirst = listdatabase.FirstOrDefault(d => d.ConnId == AppSettings.app(new string[] { "MainDB" }).ObjToString()); if (dbFirst == null) { dbFirst = listdatabase.FirstOrDefault(); @@ -61,11 +61,11 @@ namespace Blog.Core.Common.DB // 读写分离,且必须是单库模式,获取从库 - if (Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) { if (listdatabase.Count > 1) { - listdatabaseSlaveDB = listdatabase.Where(d => d.ConnId != Appsettings.app(new string[] { "MainDB" }).ObjToString()).ToList(); + listdatabaseSlaveDB = listdatabase.Where(d => d.ConnId != AppSettings.app(new string[] { "MainDB" }).ObjToString()).ToList(); } } diff --git a/Blog.Core.Common/Helper/Appsettings.cs b/Blog.Core.Common/Helper/Appsettings.cs index 0c97098..d6d0665 100644 --- a/Blog.Core.Common/Helper/Appsettings.cs +++ b/Blog.Core.Common/Helper/Appsettings.cs @@ -9,12 +9,12 @@ namespace Blog.Core.Common /// /// appsettings.json操作类 /// - public class Appsettings + public class AppSettings { public static IConfiguration Configuration { get; set; } static string contentPath { get; set; } - public Appsettings(string contentPath) + public AppSettings(string contentPath) { string Path = "appsettings.json"; @@ -27,7 +27,7 @@ namespace Blog.Core.Common .Build(); } - public Appsettings(IConfiguration configuration) + public AppSettings(IConfiguration configuration) { Configuration = configuration; } diff --git a/Blog.Core.Common/Hubs/ChatHub.cs b/Blog.Core.Common/Hubs/ChatHub.cs index 09a08c7..ff15c97 100644 --- a/Blog.Core.Common/Hubs/ChatHub.cs +++ b/Blog.Core.Common/Hubs/ChatHub.cs @@ -81,7 +81,7 @@ namespace Blog.Core.Hubs public async Task GetLatestCount(string random) { //2、服务端主动向客户端发送数据,名字千万不能错 - if (Appsettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool()) { await Clients.All.ReceiveUpdate(LogLock.GetLogData()); } diff --git a/Blog.Core.Common/LogHelper/LogLock.cs b/Blog.Core.Common/LogHelper/LogLock.cs index 5cd7668..404eb7b 100644 --- a/Blog.Core.Common/LogHelper/LogLock.cs +++ b/Blog.Core.Common/LogHelper/LogLock.cs @@ -26,7 +26,7 @@ namespace Blog.Core.Common.LogHelper public static void OutSql2Log(string prefix, string[] dataParas, bool IsHeader = true, bool isWrt = false) { - if (Appsettings.app(new string[] { "AppSettings", "LogToDb", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "AppSettings", "LogToDb", "Enabled" }).ObjToBool()) { OutSql2LogToDB(prefix, dataParas, IsHeader); } diff --git a/Blog.Core.Common/Seed/DBSeed.cs b/Blog.Core.Common/Seed/DBSeed.cs index c0cbb0c..9afdc30 100644 --- a/Blog.Core.Common/Seed/DBSeed.cs +++ b/Blog.Core.Common/Seed/DBSeed.cs @@ -36,14 +36,14 @@ namespace Blog.Core.Common.Seed SeedDataFolder = Path.Combine(WebRootPath, SeedDataFolder); Console.WriteLine("************ Blog.Core DataBase Set *****************"); - Console.WriteLine($"Is multi-DataBase: {Appsettings.app(new string[] { "MutiDBEnabled" })}"); - Console.WriteLine($"Is CQRS: {Appsettings.app(new string[] { "CQRSEnabled" })}"); + Console.WriteLine($"Is multi-DataBase: {AppSettings.app(new string[] { "MutiDBEnabled" })}"); + Console.WriteLine($"Is CQRS: {AppSettings.app(new string[] { "CQRSEnabled" })}"); Console.WriteLine(); Console.WriteLine($"Master DB ConId: {MyContext.ConnId}"); Console.WriteLine($"Master DB Type: {MyContext.DbType}"); Console.WriteLine($"Master DB ConnectString: {MyContext.ConnectionString}"); Console.WriteLine(); - if (Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) { var slaveIndex = 0; BaseDBConfig.MutiConnectionString.allDbs.Where(x => x.ConnId != MainDb.CurrentDbConnId).ToList().ForEach(m => @@ -55,7 +55,7 @@ namespace Blog.Core.Common.Seed Console.WriteLine($"--------------------------------------"); }); } - else if (Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool()) + else if (AppSettings.app(new string[] { "CQRSEnabled" }).ObjToBool()) { var slaveIndex = 0; BaseDBConfig.MutiConnectionString.slaveDbs.Where(x => x.ConnId != MainDb.CurrentDbConnId).ToList().ForEach(m => @@ -112,7 +112,7 @@ namespace Blog.Core.Common.Seed - if (Appsettings.app(new string[] { "AppSettings", "SeedDBDataEnabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "AppSettings", "SeedDBDataEnabled" }).ObjToBool()) { JsonSerializerSettings setting = new JsonSerializerSettings(); JsonConvert.DefaultSettings = new Func(() => diff --git a/Blog.Core.Common/Static/StaticPayInfo.cs b/Blog.Core.Common/Static/StaticPayInfo.cs index 4b73493..a4242bf 100644 --- a/Blog.Core.Common/Static/StaticPayInfo.cs +++ b/Blog.Core.Common/Static/StaticPayInfo.cs @@ -7,31 +7,31 @@ namespace Blog.Core.Common.Static /// /// 商户号 /// - public readonly static string MERCHANTID = Appsettings.app(new string[] { "PayInfo", "MERCHANTID" }).ObjToString(); + public readonly static string MERCHANTID = AppSettings.app(new string[] { "PayInfo", "MERCHANTID" }).ObjToString(); /// /// 柜台号 /// - public readonly static string POSID = Appsettings.app(new string[] { "PayInfo", "POSID" }).ObjToString(); + public readonly static string POSID = AppSettings.app(new string[] { "PayInfo", "POSID" }).ObjToString(); /// /// 分行号 /// - public readonly static string BRANCHID = Appsettings.app(new string[] { "PayInfo", "BRANCHID" }).ObjToString(); + public readonly static string BRANCHID = AppSettings.app(new string[] { "PayInfo", "BRANCHID" }).ObjToString(); /// /// 公钥 /// - public readonly static string pubKey = Appsettings.app(new string[] { "PayInfo", "pubKey" }).ObjToString(); + public readonly static string pubKey = AppSettings.app(new string[] { "PayInfo", "pubKey" }).ObjToString(); /// /// 操作员号 /// - public readonly static string USER_ID = Appsettings.app(new string[] { "PayInfo", "USER_ID" }).ObjToString(); + public readonly static string USER_ID = AppSettings.app(new string[] { "PayInfo", "USER_ID" }).ObjToString(); /// /// 密码 /// - public readonly static string PASSWORD = Appsettings.app(new string[] { "PayInfo", "PASSWORD" }).ObjToString(); + public readonly static string PASSWORD = AppSettings.app(new string[] { "PayInfo", "PASSWORD" }).ObjToString(); /// /// 外联平台通讯地址 /// - public readonly static string OutAddress = Appsettings.app(new string[] { "PayInfo", "OutAddress" }).ObjToString(); + public readonly static string OutAddress = AppSettings.app(new string[] { "PayInfo", "OutAddress" }).ObjToString(); } } diff --git a/Blog.Core.Extensions/AOP/BlogLogAOP.cs b/Blog.Core.Extensions/AOP/BlogLogAOP.cs index a9c38bb..86344c9 100644 --- a/Blog.Core.Extensions/AOP/BlogLogAOP.cs +++ b/Blog.Core.Extensions/AOP/BlogLogAOP.cs @@ -148,7 +148,7 @@ namespace Blog.Core.AOP { LogEx(ex, apiLogAopInfo); } - if (Appsettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Middleware", "SignalRSendLog", "Enabled" }).ObjToBool()) { _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait(); } diff --git a/Blog.Core.Extensions/Authorizations/Helpers/JwtHelper.cs b/Blog.Core.Extensions/Authorizations/Helpers/JwtHelper.cs index 46edccb..018f4c3 100644 --- a/Blog.Core.Extensions/Authorizations/Helpers/JwtHelper.cs +++ b/Blog.Core.Extensions/Authorizations/Helpers/JwtHelper.cs @@ -20,8 +20,8 @@ namespace Blog.Core.AuthHelper.OverWrite /// public static string IssueJwt(TokenModelJwt tokenModel) { - string iss = Appsettings.app(new string[] { "Audience", "Issuer" }); - string aud = Appsettings.app(new string[] { "Audience", "Audience" }); + string iss = AppSettings.app(new string[] { "Audience", "Issuer" }); + string aud = AppSettings.app(new string[] { "Audience", "Audience" }); string secret = AppSecretConfig.Audience_Secret_String; //var claims = new Claim[] //old diff --git a/Blog.Core.Extensions/Authorizations/Policys/PermissionHandler.cs b/Blog.Core.Extensions/Authorizations/Policys/PermissionHandler.cs index 32d273b..0fca02b 100644 --- a/Blog.Core.Extensions/Authorizations/Policys/PermissionHandler.cs +++ b/Blog.Core.Extensions/Authorizations/Policys/PermissionHandler.cs @@ -120,7 +120,7 @@ namespace Blog.Core.AuthHelper var result = await httpContext.AuthenticateAsync(defaultAuthenticate.Name); // 是否开启测试环境 - var isTestCurrent = Appsettings.app(new string[] { "AppSettings", "UseLoadTest" }).ObjToBool(); + var isTestCurrent = AppSettings.app(new string[] { "AppSettings", "UseLoadTest" }).ObjToBool(); //result?.Principal不为空即登录成功 if (result?.Principal != null || isTestCurrent) diff --git a/Blog.Core.Extensions/Middlewares/IpLimitMiddleware.cs b/Blog.Core.Extensions/Middlewares/IpLimitMiddleware.cs index 1a1ab34..958d6ff 100644 --- a/Blog.Core.Extensions/Middlewares/IpLimitMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/IpLimitMiddleware.cs @@ -18,7 +18,7 @@ namespace Blog.Core.Extensions.Middlewares try { - if (Appsettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool()) + if (AppSettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool()) { app.UseIpRateLimiting(); } diff --git a/Blog.Core.Extensions/Middlewares/IpLogMiddleware.cs b/Blog.Core.Extensions/Middlewares/IpLogMiddleware.cs index 39b258c..dd2930f 100644 --- a/Blog.Core.Extensions/Middlewares/IpLogMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/IpLogMiddleware.cs @@ -33,7 +33,7 @@ namespace Blog.Core.Extensions.Middlewares public async Task InvokeAsync(HttpContext context) { - if (Appsettings.app("Middleware", "IPLog", "Enabled").ObjToBool()) + if (AppSettings.app("Middleware", "IPLog", "Enabled").ObjToBool()) { // 过滤,只有接口 if (context.Request.Path.Value.Contains("api")) diff --git a/Blog.Core.Extensions/Middlewares/MiniProfilerMiddleware.cs b/Blog.Core.Extensions/Middlewares/MiniProfilerMiddleware.cs index e4d50ec..068c4a0 100644 --- a/Blog.Core.Extensions/Middlewares/MiniProfilerMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/MiniProfilerMiddleware.cs @@ -17,7 +17,7 @@ namespace Blog.Core.Extensions.Middlewares try { - if (Appsettings.app("Startup", "MiniProfiler", "Enabled").ObjToBool()) + if (AppSettings.app("Startup", "MiniProfiler", "Enabled").ObjToBool()) { // 性能分析 app.UseMiniProfiler(); diff --git a/Blog.Core.Extensions/Middlewares/QuartzJobMiddleware.cs b/Blog.Core.Extensions/Middlewares/QuartzJobMiddleware.cs index af269e8..69c52de 100644 --- a/Blog.Core.Extensions/Middlewares/QuartzJobMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/QuartzJobMiddleware.cs @@ -19,7 +19,7 @@ namespace Blog.Core.Extensions.Middlewares try { - if (Appsettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool()) + if (AppSettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool()) { var allQzServices = tasksQzServices.Query().Result; diff --git a/Blog.Core.Extensions/Middlewares/RecordAccessLogsMiddleware.cs b/Blog.Core.Extensions/Middlewares/RecordAccessLogsMiddleware.cs index 9785a3f..eb2e75f 100644 --- a/Blog.Core.Extensions/Middlewares/RecordAccessLogsMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/RecordAccessLogsMiddleware.cs @@ -45,10 +45,10 @@ namespace Blog.Core.Extensions.Middlewares public async Task InvokeAsync(HttpContext context) { - if (Appsettings.app("Middleware", "RecordAccessLogs", "Enabled").ObjToBool()) + if (AppSettings.app("Middleware", "RecordAccessLogs", "Enabled").ObjToBool()) { var api = context.Request.Path.ObjToString().TrimEnd('/').ToLower(); - var ignoreApis = Appsettings.app("Middleware", "RecordAccessLogs", "IgnoreApis"); + var ignoreApis = AppSettings.app("Middleware", "RecordAccessLogs", "IgnoreApis"); // 过滤,只有接口 if (api.Contains("api") && !ignoreApis.Contains(api)) diff --git a/Blog.Core.Extensions/Middlewares/RequRespLogMiddleware.cs b/Blog.Core.Extensions/Middlewares/RequRespLogMiddleware.cs index e69e747..4ecde84 100644 --- a/Blog.Core.Extensions/Middlewares/RequRespLogMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/RequRespLogMiddleware.cs @@ -35,7 +35,7 @@ namespace Blog.Core.Extensions.Middlewares public async Task InvokeAsync(HttpContext context) { - if (Appsettings.app("Middleware", "RequestResponseLog", "Enabled").ObjToBool()) + if (AppSettings.app("Middleware", "RequestResponseLog", "Enabled").ObjToBool()) { // 过滤,只有接口 if (context.Request.Path.Value.Contains("api")) diff --git a/Blog.Core.Extensions/Middlewares/SeedDataMiddleware.cs b/Blog.Core.Extensions/Middlewares/SeedDataMiddleware.cs index 34af1a8..ad944bf 100644 --- a/Blog.Core.Extensions/Middlewares/SeedDataMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/SeedDataMiddleware.cs @@ -18,7 +18,7 @@ namespace Blog.Core.Extensions.Middlewares try { - if (Appsettings.app("AppSettings", "SeedDBEnabled").ObjToBool() || Appsettings.app("AppSettings", "SeedDBDataEnabled").ObjToBool()) + if (AppSettings.app("AppSettings", "SeedDBEnabled").ObjToBool() || AppSettings.app("AppSettings", "SeedDBDataEnabled").ObjToBool()) { DBSeed.SeedAsync(myContext, webRootPath).Wait(); } diff --git a/Blog.Core.Extensions/Middlewares/SignalRSendMiddleware.cs b/Blog.Core.Extensions/Middlewares/SignalRSendMiddleware.cs index ed96f43..1909c08 100644 --- a/Blog.Core.Extensions/Middlewares/SignalRSendMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/SignalRSendMiddleware.cs @@ -34,7 +34,7 @@ namespace Blog.Core.Extensions.Middlewares public async Task InvokeAsync(HttpContext context) { - if (Appsettings.app("Middleware", "SignalR", "Enabled").ObjToBool()) + if (AppSettings.app("Middleware", "SignalR", "Enabled").ObjToBool()) { await _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()); } diff --git a/Blog.Core.Extensions/Middlewares/SwaggerMiddleware.cs b/Blog.Core.Extensions/Middlewares/SwaggerMiddleware.cs index 5188237..34dfd04 100644 --- a/Blog.Core.Extensions/Middlewares/SwaggerMiddleware.cs +++ b/Blog.Core.Extensions/Middlewares/SwaggerMiddleware.cs @@ -22,7 +22,7 @@ namespace Blog.Core.Extensions.Middlewares app.UseSwaggerUI(c => { //根据版本名称倒序 遍历展示 - var apiName = Appsettings.app(new string[] { "Startup", "ApiName" }); + var apiName = AppSettings.app(new string[] { "Startup", "ApiName" }); typeof(ApiVersions).GetEnumNames().OrderByDescending(e => e).ToList().ForEach(version => { c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"{apiName} {version}"); diff --git a/Blog.Core.Extensions/Redis/RedisCacheManager.cs b/Blog.Core.Extensions/Redis/RedisCacheManager.cs index ab4704d..0e5d781 100644 --- a/Blog.Core.Extensions/Redis/RedisCacheManager.cs +++ b/Blog.Core.Extensions/Redis/RedisCacheManager.cs @@ -15,7 +15,7 @@ namespace Blog.Core.Extensions public RedisCacheManager() { - string redisConfiguration = Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "ConnectionString" });//获取连接字符串 + string redisConfiguration = AppSettings.app(new string[] { "AppSettings", "RedisCachingAOP", "ConnectionString" });//获取连接字符串 if (string.IsNullOrWhiteSpace(redisConfiguration)) { diff --git a/Blog.Core.Extensions/ServiceExtensions/AppConfigSetup.cs b/Blog.Core.Extensions/ServiceExtensions/AppConfigSetup.cs index 31ae349..0622e76 100644 --- a/Blog.Core.Extensions/ServiceExtensions/AppConfigSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/AppConfigSetup.cs @@ -19,7 +19,7 @@ namespace Blog.Core.Extensions { if (services == null) throw new ArgumentNullException(nameof(services)); - if (Appsettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool()) { if (env.IsDevelopment()) { @@ -42,7 +42,7 @@ namespace Blog.Core.Extensions } // Redis缓存AOP - if (!Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool()) { Console.WriteLine($"Redis Caching AOP: False"); } @@ -52,7 +52,7 @@ namespace Blog.Core.Extensions } // 内存缓存AOP - if (!Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool()) { Console.WriteLine($"Memory Caching AOP: False"); } @@ -62,7 +62,7 @@ namespace Blog.Core.Extensions } // 服务日志AOP - if (!Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool()) { Console.WriteLine($"Service Log AOP: False"); } @@ -72,9 +72,9 @@ namespace Blog.Core.Extensions } // 开启的中间件日志 - var requestResponseLogOpen = Appsettings.app(new string[] { "Middleware", "RequestResponseLog", "Enabled" }).ObjToBool(); - var ipLogOpen = Appsettings.app(new string[] { "Middleware", "IPLog", "Enabled" }).ObjToBool(); - var recordAccessLogsOpen = Appsettings.app(new string[] { "Middleware", "RecordAccessLogs", "Enabled" }).ObjToBool(); + var requestResponseLogOpen = AppSettings.app(new string[] { "Middleware", "RequestResponseLog", "Enabled" }).ObjToBool(); + var ipLogOpen = AppSettings.app(new string[] { "Middleware", "IPLog", "Enabled" }).ObjToBool(); + var recordAccessLogsOpen = AppSettings.app(new string[] { "Middleware", "RecordAccessLogs", "Enabled" }).ObjToBool(); ConsoleHelper.WriteSuccessLine($"OPEN Log: " + (requestResponseLogOpen ? "RequestResponseLog √," : "") + (ipLogOpen ? "IPLog √," : "") + @@ -82,7 +82,7 @@ namespace Blog.Core.Extensions ); // 事务AOP - if (!Appsettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool()) { Console.WriteLine($"Transaction AOP: False"); } @@ -92,7 +92,7 @@ namespace Blog.Core.Extensions } // 数据库Sql执行AOP - if (!Appsettings.app(new string[] { "AppSettings", "SqlAOP", "OutToLogFile", "Enabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "AppSettings", "SqlAOP", "OutToLogFile", "Enabled" }).ObjToBool()) { Console.WriteLine($"DB Sql AOP To LogFile: False"); } @@ -102,7 +102,7 @@ namespace Blog.Core.Extensions } // Sql执行日志输出到控制台 - if (!Appsettings.app(new string[] { "AppSettings", "SqlAOP", "OutToConsole", "Enabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "AppSettings", "SqlAOP", "OutToConsole", "Enabled" }).ObjToBool()) { Console.WriteLine($"DB Sql AOP To Console: False"); } @@ -112,7 +112,7 @@ namespace Blog.Core.Extensions } // SingnalR发送数据 - if (!Appsettings.app(new string[] { "Middleware", "SignalR", "Enabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "Middleware", "SignalR", "Enabled" }).ObjToBool()) { Console.WriteLine($"SignalR send data: False"); } @@ -122,7 +122,7 @@ namespace Blog.Core.Extensions } // IP限流 - if (!Appsettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool()) + if (!AppSettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool()) { Console.WriteLine($"IpRateLimiting: False"); } @@ -132,7 +132,7 @@ namespace Blog.Core.Extensions } // 性能分析 - if (!Appsettings.app("Startup", "MiniProfiler", "Enabled").ObjToBool()) + if (!AppSettings.app("Startup", "MiniProfiler", "Enabled").ObjToBool()) { Console.WriteLine($"MiniProfiler: False"); } @@ -142,7 +142,7 @@ namespace Blog.Core.Extensions } // CORS跨域 - if (!Appsettings.app("Startup", "Cors", "EnableAllIPs").ObjToBool()) + if (!AppSettings.app("Startup", "Cors", "EnableAllIPs").ObjToBool()) { Console.WriteLine($"EnableAllIPs For CORS: False"); } @@ -152,7 +152,7 @@ namespace Blog.Core.Extensions } // redis消息队列 - if (!Appsettings.app("Startup", "RedisMq", "Enabled").ObjToBool()) + if (!AppSettings.app("Startup", "RedisMq", "Enabled").ObjToBool()) { Console.WriteLine($"Redis MQ: False"); } @@ -162,7 +162,7 @@ namespace Blog.Core.Extensions } // RabbitMQ 消息队列 - if (!Appsettings.app("RabbitMQ", "Enabled").ObjToBool()) + if (!AppSettings.app("RabbitMQ", "Enabled").ObjToBool()) { Console.WriteLine($"RabbitMQ: False"); } @@ -172,7 +172,7 @@ namespace Blog.Core.Extensions } // Consul 注册服务 - if (!Appsettings.app("Middleware", "Consul", "Enabled").ObjToBool()) + if (!AppSettings.app("Middleware", "Consul", "Enabled").ObjToBool()) { Console.WriteLine($"Consul service: False"); } @@ -182,7 +182,7 @@ namespace Blog.Core.Extensions } // EventBus 事件总线 - if (!Appsettings.app("EventBus", "Enabled").ObjToBool()) + if (!AppSettings.app("EventBus", "Enabled").ObjToBool()) { Console.WriteLine($"EventBus: False"); } @@ -192,7 +192,7 @@ namespace Blog.Core.Extensions } // 多库 - if (!Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) { Console.WriteLine($"Is multi-DataBase: False"); } @@ -202,7 +202,7 @@ namespace Blog.Core.Extensions } // 读写分离 - if (!Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool()) + if (!AppSettings.app(new string[] { "CQRSEnabled" }).ObjToBool()) { Console.WriteLine($"Is CQRS: False"); } @@ -220,7 +220,7 @@ namespace Blog.Core.Extensions { if (services == null) throw new ArgumentNullException(nameof(services)); - if (Appsettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool()) { if (env.IsDevelopment()) @@ -234,12 +234,12 @@ namespace Blog.Core.Extensions { new string[] { "当前环境", Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") }, new string[] { "当前的授权方案", Permissions.IsUseIds4 ? "Ids4" : "JWT" }, - new string[] { "CORS跨域", Appsettings.app("Startup", "Cors", "EnableAllIPs") }, - new string[] { "RabbitMQ消息列队", Appsettings.app("RabbitMQ", "Enabled") }, - new string[] { "事件总线(必须开启消息列队)", Appsettings.app("EventBus", "Enabled") }, - new string[] { "redis消息队列", Appsettings.app("Startup", "RedisMq", "Enabled") }, - new string[] { "是否多库", Appsettings.app("MutiDBEnabled" ) }, - new string[] { "读写分离", Appsettings.app("CQRSEnabled") }, + new string[] { "CORS跨域", AppSettings.app("Startup", "Cors", "EnableAllIPs") }, + new string[] { "RabbitMQ消息列队", AppSettings.app("RabbitMQ", "Enabled") }, + new string[] { "事件总线(必须开启消息列队)", AppSettings.app("EventBus", "Enabled") }, + new string[] { "redis消息队列", AppSettings.app("Startup", "RedisMq", "Enabled") }, + new string[] { "是否多库", AppSettings.app("MutiDBEnabled" ) }, + new string[] { "读写分离", AppSettings.app("CQRSEnabled") }, }; new ConsoleTable() @@ -258,12 +258,12 @@ namespace Blog.Core.Extensions #region AOP List aopInfos = new() { - new string[] { "Redis缓存AOP", Appsettings.app("AppSettings", "RedisCachingAOP", "Enabled") }, - new string[] { "内存缓存AOP", Appsettings.app("AppSettings", "MemoryCachingAOP", "Enabled") }, - new string[] { "服务日志AOP", Appsettings.app("AppSettings", "LogAOP", "Enabled" ) }, - new string[] { "事务AOP", Appsettings.app("AppSettings", "TranAOP", "Enabled" ) }, - new string[] { "Sql执行AOP", Appsettings.app("AppSettings", "SqlAOP", "OutToLogFile", "Enabled" ) }, - new string[] { "Sql执行AOP控制台输出", Appsettings.app("AppSettings", "SqlAOP", "OutToConsole", "Enabled" ) }, + new string[] { "Redis缓存AOP", AppSettings.app("AppSettings", "RedisCachingAOP", "Enabled") }, + new string[] { "内存缓存AOP", AppSettings.app("AppSettings", "MemoryCachingAOP", "Enabled") }, + new string[] { "服务日志AOP", AppSettings.app("AppSettings", "LogAOP", "Enabled" ) }, + new string[] { "事务AOP", AppSettings.app("AppSettings", "TranAOP", "Enabled" ) }, + new string[] { "Sql执行AOP", AppSettings.app("AppSettings", "SqlAOP", "OutToLogFile", "Enabled" ) }, + new string[] { "Sql执行AOP控制台输出", AppSettings.app("AppSettings", "SqlAOP", "OutToConsole", "Enabled" ) }, }; new ConsoleTable @@ -282,13 +282,13 @@ namespace Blog.Core.Extensions #region 中间件 List MiddlewareInfos = new() { - new string[] { "请求纪录中间件", Appsettings.app("Middleware", "RecordAccessLogs", "Enabled") }, - new string[] { "IP记录中间件", Appsettings.app("Middleware", "IPLog", "Enabled" ) }, - new string[] { "请求响应日志中间件", Appsettings.app("Middleware", "RequestResponseLog", "Enabled" ) }, - new string[] { "SingnalR实时发送请求数据中间件", Appsettings.app("Middleware", "SignalR", "Enabled" ) }, - new string[] { "IP限流中间件", Appsettings.app("Middleware", "IpRateLimit", "Enabled") }, - new string[] { "性能分析中间件", Appsettings.app("Startup", "MiniProfiler", "Enabled") }, - new string[] { "Consul注册服务", Appsettings.app("Middleware", "Consul", "Enabled") }, + new string[] { "请求纪录中间件", AppSettings.app("Middleware", "RecordAccessLogs", "Enabled") }, + new string[] { "IP记录中间件", AppSettings.app("Middleware", "IPLog", "Enabled" ) }, + new string[] { "请求响应日志中间件", AppSettings.app("Middleware", "RequestResponseLog", "Enabled" ) }, + new string[] { "SingnalR实时发送请求数据中间件", AppSettings.app("Middleware", "SignalR", "Enabled" ) }, + new string[] { "IP限流中间件", AppSettings.app("Middleware", "IpRateLimit", "Enabled") }, + new string[] { "性能分析中间件", AppSettings.app("Startup", "MiniProfiler", "Enabled") }, + new string[] { "Consul注册服务", AppSettings.app("Middleware", "Consul", "Enabled") }, }; new ConsoleTable diff --git a/Blog.Core.Extensions/ServiceExtensions/Authentication_Ids4Setup.cs b/Blog.Core.Extensions/ServiceExtensions/Authentication_Ids4Setup.cs index c91691d..aa8c8bd 100644 --- a/Blog.Core.Extensions/ServiceExtensions/Authentication_Ids4Setup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/Authentication_Ids4Setup.cs @@ -26,9 +26,9 @@ namespace Blog.Core.Extensions }) .AddJwtBearer(options => { - options.Authority = Appsettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" }); + options.Authority = AppSettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" }); options.RequireHttpsMetadata = false; - options.Audience = Appsettings.app(new string[] { "Startup", "IdentityServer4", "ApiName" }); + options.Audience = AppSettings.app(new string[] { "Startup", "IdentityServer4", "ApiName" }); }) .AddScheme(nameof(ApiResponseHandler), o => { }); } diff --git a/Blog.Core.Extensions/ServiceExtensions/Authentication_JWTSetup.cs b/Blog.Core.Extensions/ServiceExtensions/Authentication_JWTSetup.cs index 223197a..930bfb6 100644 --- a/Blog.Core.Extensions/ServiceExtensions/Authentication_JWTSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/Authentication_JWTSetup.cs @@ -26,8 +26,8 @@ namespace Blog.Core.Extensions var symmetricKeyAsBase64 = AppSecretConfig.Audience_Secret_String; var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64); var signingKey = new SymmetricSecurityKey(keyByteArray); - var Issuer = Appsettings.app(new string[] { "Audience", "Issuer" }); - var Audience = Appsettings.app(new string[] { "Audience", "Audience" }); + var Issuer = AppSettings.app(new string[] { "Audience", "Issuer" }); + var Audience = AppSettings.app(new string[] { "Audience", "Audience" }); var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256); diff --git a/Blog.Core.Extensions/ServiceExtensions/AuthorizationSetup.cs b/Blog.Core.Extensions/ServiceExtensions/AuthorizationSetup.cs index ae64a5e..ae0a638 100644 --- a/Blog.Core.Extensions/ServiceExtensions/AuthorizationSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/AuthorizationSetup.cs @@ -45,8 +45,8 @@ namespace Blog.Core.Extensions var symmetricKeyAsBase64 = AppSecretConfig.Audience_Secret_String; var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64); var signingKey = new SymmetricSecurityKey(keyByteArray); - var Issuer = Appsettings.app(new string[] { "Audience", "Issuer" }); - var Audience = Appsettings.app(new string[] { "Audience", "Audience" }); + var Issuer = AppSettings.app(new string[] { "Audience", "Issuer" }); + var Audience = AppSettings.app(new string[] { "Audience", "Audience" }); var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256); diff --git a/Blog.Core.Extensions/ServiceExtensions/AutofacModuleRegister.cs b/Blog.Core.Extensions/ServiceExtensions/AutofacModuleRegister.cs index 2ca19db..1da6cb3 100644 --- a/Blog.Core.Extensions/ServiceExtensions/AutofacModuleRegister.cs +++ b/Blog.Core.Extensions/ServiceExtensions/AutofacModuleRegister.cs @@ -42,25 +42,25 @@ namespace Blog.Core.Extensions // AOP 开关,如果想要打开指定的功能,只需要在 appsettigns.json 对应对应 true 就行。 var cacheType = new List(); - if (Appsettings.app(new string[] {"AppSettings", "RedisCachingAOP", "Enabled"}).ObjToBool()) + if (AppSettings.app(new string[] {"AppSettings", "RedisCachingAOP", "Enabled"}).ObjToBool()) { builder.RegisterType(); cacheType.Add(typeof(BlogRedisCacheAOP)); } - if (Appsettings.app(new string[] {"AppSettings", "MemoryCachingAOP", "Enabled"}).ObjToBool()) + if (AppSettings.app(new string[] {"AppSettings", "MemoryCachingAOP", "Enabled"}).ObjToBool()) { builder.RegisterType(); cacheType.Add(typeof(BlogCacheAOP)); } - if (Appsettings.app(new string[] {"AppSettings", "TranAOP", "Enabled"}).ObjToBool()) + if (AppSettings.app(new string[] {"AppSettings", "TranAOP", "Enabled"}).ObjToBool()) { builder.RegisterType(); cacheType.Add(typeof(BlogTranAOP)); } - if (Appsettings.app(new string[] {"AppSettings", "LogAOP", "Enabled"}).ObjToBool()) + if (AppSettings.app(new string[] {"AppSettings", "LogAOP", "Enabled"}).ObjToBool()) { builder.RegisterType(); cacheType.Add(typeof(BlogLogAOP)); diff --git a/Blog.Core.Extensions/ServiceExtensions/CorsSetup.cs b/Blog.Core.Extensions/ServiceExtensions/CorsSetup.cs index 3f1c14b..d9961ff 100644 --- a/Blog.Core.Extensions/ServiceExtensions/CorsSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/CorsSetup.cs @@ -15,15 +15,15 @@ namespace Blog.Core.Extensions services.AddCors(c => { - if (!Appsettings.app(new string[] { "Startup", "Cors", "EnableAllIPs" }).ObjToBool()) + if (!AppSettings.app(new string[] { "Startup", "Cors", "EnableAllIPs" }).ObjToBool()) { - c.AddPolicy(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }), + c.AddPolicy(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" }), policy => { policy - .WithOrigins(Appsettings.app(new string[] { "Startup", "Cors", "IPs" }).Split(',')) + .WithOrigins(AppSettings.app(new string[] { "Startup", "Cors", "IPs" }).Split(',')) .AllowAnyHeader()//Ensures that the policy allows any header. .AllowAnyMethod(); }); @@ -31,7 +31,7 @@ namespace Blog.Core.Extensions else { //允许任意跨域请求 - c.AddPolicy(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }), + c.AddPolicy(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" }), policy => { policy diff --git a/Blog.Core.Extensions/ServiceExtensions/EventBusSetup.cs b/Blog.Core.Extensions/ServiceExtensions/EventBusSetup.cs index 44e15c7..1aae5ed 100644 --- a/Blog.Core.Extensions/ServiceExtensions/EventBusSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/EventBusSetup.cs @@ -18,14 +18,14 @@ namespace Blog.Core.Extensions { if (services == null) throw new ArgumentNullException(nameof(services)); - if (Appsettings.app(new string[] { "EventBus", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "EventBus", "Enabled" }).ObjToBool()) { - var subscriptionClientName = Appsettings.app(new string[] { "EventBus", "SubscriptionClientName" }); + var subscriptionClientName = AppSettings.app(new string[] { "EventBus", "SubscriptionClientName" }); services.AddSingleton(); services.AddTransient(); - if (Appsettings.app(new string[] { "RabbitMQ", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "RabbitMQ", "Enabled" }).ObjToBool()) { services.AddSingleton(sp => { @@ -35,15 +35,15 @@ namespace Blog.Core.Extensions var eventBusSubcriptionsManager = sp.GetRequiredService(); var retryCount = 5; - if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "RetryCount" }))) + if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "RetryCount" }))) { - retryCount = int.Parse(Appsettings.app(new string[] { "RabbitMQ", "RetryCount" })); + retryCount = int.Parse(AppSettings.app(new string[] { "RabbitMQ", "RetryCount" })); } return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount); }); } - if(Appsettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool()) + if(AppSettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool()) { services.AddHostedService(); services.AddSingleton(); @@ -54,7 +54,7 @@ namespace Blog.Core.Extensions public static void ConfigureEventBus(this IApplicationBuilder app) { - if (Appsettings.app(new string[] { "EventBus", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "EventBus", "Enabled" }).ObjToBool()) { var eventBus = app.ApplicationServices.GetRequiredService(); diff --git a/Blog.Core.Extensions/ServiceExtensions/KafkaSetup.cs b/Blog.Core.Extensions/ServiceExtensions/KafkaSetup.cs index 79e60b9..0dbc3d0 100644 --- a/Blog.Core.Extensions/ServiceExtensions/KafkaSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/KafkaSetup.cs @@ -16,7 +16,7 @@ namespace Blog.Core.Extensions { if (services == null) throw new ArgumentNullException(nameof(services)); - if (Appsettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool()) { services.Configure(configuration.GetSection("kafka")); services.AddSingleton(); diff --git a/Blog.Core.Extensions/ServiceExtensions/MiniProfilerSetup.cs b/Blog.Core.Extensions/ServiceExtensions/MiniProfilerSetup.cs index 811cac6..a40d684 100644 --- a/Blog.Core.Extensions/ServiceExtensions/MiniProfilerSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/MiniProfilerSetup.cs @@ -12,7 +12,7 @@ namespace Blog.Core.Extensions public static void AddMiniProfilerSetup(this IServiceCollection services) { if (services == null) throw new ArgumentNullException(nameof(services)); - if(Appsettings.app(new string[] { "Startup", "MiniProfiler", "Enabled" }).ObjToBool()) + if(AppSettings.app(new string[] { "Startup", "MiniProfiler", "Enabled" }).ObjToBool()) { services.AddMiniProfiler(); } diff --git a/Blog.Core.Extensions/ServiceExtensions/NacosSetup.cs b/Blog.Core.Extensions/ServiceExtensions/NacosSetup.cs index c886332..1854f3e 100644 --- a/Blog.Core.Extensions/ServiceExtensions/NacosSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/NacosSetup.cs @@ -19,7 +19,7 @@ namespace Blog.Core.Extensions // 在实际生产工作中 本地开发是不需要注册nacos的 所以根据环境变量去判断 // 比如 开发环境 dev 测试环境 test 生产 prod 只有这几种环境变量的时候才需要去注册nacos - if (Appsettings.app(new string[] { "Startup", "Nacos", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Startup", "Nacos", "Enabled" }).ObjToBool()) { // 从当前配置取文件去注册naocs services.AddNacosV2Config(x => diff --git a/Blog.Core.Extensions/ServiceExtensions/RabbitMQSetup.cs b/Blog.Core.Extensions/ServiceExtensions/RabbitMQSetup.cs index 91ffcff..72b72f4 100644 --- a/Blog.Core.Extensions/ServiceExtensions/RabbitMQSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/RabbitMQSetup.cs @@ -16,7 +16,7 @@ namespace Blog.Core.Extensions { if (services == null) throw new ArgumentNullException(nameof(services)); - if (Appsettings.app(new string[] { "RabbitMQ", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "RabbitMQ", "Enabled" }).ObjToBool()) { services.AddSingleton(sp => { @@ -24,29 +24,29 @@ namespace Blog.Core.Extensions var factory = new ConnectionFactory() { - HostName = Appsettings.app(new string[] { "RabbitMQ", "Connection" }), + HostName = AppSettings.app(new string[] { "RabbitMQ", "Connection" }), DispatchConsumersAsync = true }; - if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "UserName" }))) + if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "UserName" }))) { - factory.UserName = Appsettings.app(new string[] { "RabbitMQ", "UserName" }); + factory.UserName = AppSettings.app(new string[] { "RabbitMQ", "UserName" }); } - if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "Password" }))) + if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "Password" }))) { - factory.Password = Appsettings.app(new string[] { "RabbitMQ", "Password" }); + factory.Password = AppSettings.app(new string[] { "RabbitMQ", "Password" }); } - if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "Port" }))) + if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "Port" }))) { - factory.Port = Appsettings.app(new string[] { "RabbitMQ", "Port" }).ObjToInt(); + factory.Port = AppSettings.app(new string[] { "RabbitMQ", "Port" }).ObjToInt(); } var retryCount = 5; - if (!string.IsNullOrEmpty(Appsettings.app(new string[] { "RabbitMQ", "RetryCount" }))) + if (!string.IsNullOrEmpty(AppSettings.app(new string[] { "RabbitMQ", "RetryCount" }))) { - retryCount = Appsettings.app(new string[] { "RabbitMQ", "RetryCount" }).ObjToInt(); + retryCount = AppSettings.app(new string[] { "RabbitMQ", "RetryCount" }).ObjToInt(); } return new RabbitMQPersistentConnection(factory, logger, retryCount); diff --git a/Blog.Core.Extensions/ServiceExtensions/RedisCacheSetup.cs b/Blog.Core.Extensions/ServiceExtensions/RedisCacheSetup.cs index 568742e..e070cbd 100644 --- a/Blog.Core.Extensions/ServiceExtensions/RedisCacheSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/RedisCacheSetup.cs @@ -20,7 +20,7 @@ namespace Blog.Core.Extensions services.AddSingleton(sp => { //获取连接字符串 - string redisConfiguration = Appsettings.app(new string[] { "Redis", "ConnectionString" }); + string redisConfiguration = AppSettings.app(new string[] { "Redis", "ConnectionString" }); var configuration = ConfigurationOptions.Parse(redisConfiguration, true); diff --git a/Blog.Core.Extensions/ServiceExtensions/RedisInitMqSetup.cs b/Blog.Core.Extensions/ServiceExtensions/RedisInitMqSetup.cs index 9b6f281..b96b81b 100644 --- a/Blog.Core.Extensions/ServiceExtensions/RedisInitMqSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/RedisInitMqSetup.cs @@ -16,7 +16,7 @@ namespace Blog.Core.Extensions { if (services == null) throw new ArgumentNullException(nameof(services)); - if (Appsettings.app(new string[] { "Startup", "RedisMq", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "Startup", "RedisMq", "Enabled" }).ObjToBool()) { // services.AddInitQ(m => @@ -24,7 +24,7 @@ namespace Blog.Core.Extensions //时间间隔 m.SuspendTime = 2000; //redis服务器地址 - m.ConnectionString = Appsettings.app(new string[] { "Redis", "ConnectionString" }); + m.ConnectionString = AppSettings.app(new string[] { "Redis", "ConnectionString" }); //对应的订阅者类,需要new一个实例对象,当然你也可以传参,比如日志对象 m.ListSubscribe = new List() { typeof(RedisSubscribe), diff --git a/Blog.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs b/Blog.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs index d152852..cec466a 100644 --- a/Blog.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs @@ -24,7 +24,7 @@ namespace Blog.Core.Extensions if (services == null) throw new ArgumentNullException(nameof(services)); // 默认添加主数据库连接 - MainDb.CurrentDbConnId = Appsettings.app(new string[] { "MainDB" }); + MainDb.CurrentDbConnId = AppSettings.app(new string[] { "MainDB" }); // SqlSugarScope是线程安全,可使用单例注入 // 参考:https://www.donet5.com/Home/Doc?typeId=1181 @@ -59,9 +59,9 @@ namespace Blog.Core.Extensions { OnLogExecuting = (sql, p) => { - if (Appsettings.app(new string[] { "AppSettings", "SqlAOP", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "AppSettings", "SqlAOP", "Enabled" }).ObjToBool()) { - if (Appsettings.app(new string[] { "AppSettings", "SqlAOP", "OutToLogFile", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "AppSettings", "SqlAOP", "OutToLogFile", "Enabled" }).ObjToBool()) { Parallel.For(0, 1, e => { @@ -70,7 +70,7 @@ namespace Blog.Core.Extensions }); } - if (Appsettings.app(new string[] { "AppSettings", "SqlAOP", "OutToConsole", "Enabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "AppSettings", "SqlAOP", "OutToConsole", "Enabled" }).ObjToBool()) { ConsoleHelper.WriteColorLine(string.Join("\r\n", new string[] { "--------", "【SQL语句】:" + GetWholeSql(p, sql) }), ConsoleColor.DarkCyan); } diff --git a/Blog.Core.Extensions/ServiceExtensions/SwaggerSetup.cs b/Blog.Core.Extensions/ServiceExtensions/SwaggerSetup.cs index 0acb131..449b6a4 100644 --- a/Blog.Core.Extensions/ServiceExtensions/SwaggerSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/SwaggerSetup.cs @@ -27,7 +27,7 @@ namespace Blog.Core.Extensions var basePath = AppContext.BaseDirectory; //var basePath2 = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath; - var ApiName = Appsettings.app(new string[] { "Startup", "ApiName" }); + var ApiName = AppSettings.app(new string[] { "Startup", "ApiName" }); services.AddSwaggerGen(c => { @@ -81,7 +81,7 @@ namespace Blog.Core.Extensions { Implicit = new OpenApiOAuthFlow { - AuthorizationUrl = new Uri($"{Appsettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" })}/connect/authorize"), + AuthorizationUrl = new Uri($"{AppSettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" })}/connect/authorize"), Scopes = new Dictionary { { "blog.core.api","ApiResource id" diff --git a/Blog.Core.Gateway/Helper/CustomJwtTokenAuthMiddleware.cs b/Blog.Core.Gateway/Helper/CustomJwtTokenAuthMiddleware.cs index 6c7d048..88181bc 100644 --- a/Blog.Core.Gateway/Helper/CustomJwtTokenAuthMiddleware.cs +++ b/Blog.Core.Gateway/Helper/CustomJwtTokenAuthMiddleware.cs @@ -35,7 +35,7 @@ namespace Blog.Core.AuthHelper private readonly RequestDelegate _next; - public CustomJwtTokenAuthMiddleware(INacosNamingService serv, RequestDelegate next, IAuthenticationSchemeProvider schemes, Appsettings appset,ICaching cache) + public CustomJwtTokenAuthMiddleware(INacosNamingService serv, RequestDelegate next, IAuthenticationSchemeProvider schemes, AppSettings appset,ICaching cache) { NacosServClient = serv; _cache = cache; @@ -129,9 +129,9 @@ namespace Blog.Core.AuthHelper { try { - string PermissionServName = Appsettings.GetValue("ApiGateWay:PermissionServName"); - string PermissionServGroup = Appsettings.GetValue("ApiGateWay:PermissionServGroup"); - string PermissionServUrl = Appsettings.GetValue("ApiGateWay:PermissionServUrl"); + string PermissionServName = AppSettings.GetValue("ApiGateWay:PermissionServName"); + string PermissionServGroup = AppSettings.GetValue("ApiGateWay:PermissionServGroup"); + string PermissionServUrl = AppSettings.GetValue("ApiGateWay:PermissionServUrl"); string requestdata = await NacosServClient.Cof_NaoceGet(PermissionServName, PermissionServGroup, PermissionServUrl); if (string.IsNullOrEmpty(requestdata)) return null; @@ -168,7 +168,7 @@ namespace Blog.Core.AuthHelper /// public bool CheckWhiteList(string url) { - List WhiteList = _cache.Cof_GetICaching>("WhiteList", () => Appsettings.app("WhiteList"), 10); + List WhiteList = _cache.Cof_GetICaching>("WhiteList", () => AppSettings.app("WhiteList"), 10); if (!WhiteList.Cof_CheckAvailable()) return false; foreach (var Urlitem in WhiteList) @@ -189,7 +189,7 @@ namespace Blog.Core.AuthHelper public bool CheckBlackList(string url) { - List BlackList = _cache.Cof_GetICaching>("BlackList", () => Appsettings.app("BlackList"), 10); + List BlackList = _cache.Cof_GetICaching>("BlackList", () => AppSettings.app("BlackList"), 10); if (!BlackList.Cof_CheckAvailable()) return false; foreach (var Urlitem in BlackList) diff --git a/Blog.Core.Gateway/Helper/OcelotConfigurationTask.cs b/Blog.Core.Gateway/Helper/OcelotConfigurationTask.cs index 5bb2639..a95df86 100644 --- a/Blog.Core.Gateway/Helper/OcelotConfigurationTask.cs +++ b/Blog.Core.Gateway/Helper/OcelotConfigurationTask.cs @@ -46,10 +46,10 @@ namespace ApiGateway.Helper _servClient = serv; nacosConfigListener.internalConfigurationRepo = _internalConfigurationRepo; nacosConfigListener.internalConfigurationCreator = _internalConfigurationCreator; - OcelotConfig = Appsettings.GetValue("ApiGateWay:OcelotConfig"); - OcelotConfigGroup = Appsettings.GetValue("ApiGateWay:OcelotConfigGroup"); - AppConfig = Appsettings.GetValue("ApiGateWay:AppConfig"); - AppConfigGroup = Appsettings.GetValue("ApiGateWay:AppConfigGroup"); + OcelotConfig = AppSettings.GetValue("ApiGateWay:OcelotConfig"); + OcelotConfigGroup = AppSettings.GetValue("ApiGateWay:OcelotConfigGroup"); + AppConfig = AppSettings.GetValue("ApiGateWay:AppConfig"); + AppConfigGroup = AppSettings.GetValue("ApiGateWay:AppConfigGroup"); @@ -141,7 +141,7 @@ namespace ApiGateway.Helper // 当前监听到配置配置 应该重新断开 重连 刷新等一些中间件操作 // 比如 mq redis 等其他跟配置相关的中间件 JsonConfigSettings.Configuration = configuration; - Appsettings.Configuration = configuration; + AppSettings.Configuration = configuration; } } } diff --git a/Blog.Core.Gateway/Startup.cs b/Blog.Core.Gateway/Startup.cs index 23c5caa..552b4ef 100644 --- a/Blog.Core.Gateway/Startup.cs +++ b/Blog.Core.Gateway/Startup.cs @@ -32,7 +32,7 @@ namespace Blog.Core.AdminMvc // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - services.AddSingleton(new Appsettings(Configuration)); + services.AddSingleton(new AppSettings(Configuration)); services.AddAuthentication_JWTSetup(); @@ -71,7 +71,7 @@ namespace Blog.Core.AdminMvc app.UseCustomSwaggerMildd(); - app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" })); + app.UseCors(AppSettings.app(new string[] { "Startup", "Cors", "PolicyName" })); app.UseEndpoints(endpoints => { diff --git a/Blog.Core.Model/Models/sysUserInfo.cs b/Blog.Core.Model/Models/sysUserInfo.cs index 4eb482c..5f433cf 100644 --- a/Blog.Core.Model/Models/sysUserInfo.cs +++ b/Blog.Core.Model/Models/sysUserInfo.cs @@ -7,7 +7,8 @@ namespace Blog.Core.Model.Models /// /// 用户信息表 /// - [SugarTable("SysUserInfo")] + //[SugarTable("SysUserInfo")] + [SugarTable("SysUserInfo", "用户表")]//('数据库表名','数据库表备注') public class SysUserInfo : SysUserInfoRoot { public SysUserInfo() @@ -30,7 +31,11 @@ namespace Blog.Core.Model.Models /// /// 登录账号 /// - [SugarColumn(Length = 200, IsNullable = true)] + [SugarColumn(Length = 200, IsNullable = true, ColumnDescription = "登录账号")] + //:eg model 根据sqlsugar的完整定义可以如下定义,ColumnDescription可定义表字段备注 + //[SugarColumn(IsNullable = false, ColumnDescription = "登录账号", IsPrimaryKey = false, IsIdentity = false, ColumnDataType = "nvarchar", Length = 50)] + //ColumnDescription 表字段备注, 已在MSSQL测试,配合 [SugarTable("SysUserInfo", "用户表")]//('数据库表名','数据库表备注') + //可以完整生成 表备注和各个字段的中文备注 public string LoginName { get; set; } /// diff --git a/Blog.Core.Repository/BASE/BaseRepository.cs b/Blog.Core.Repository/BASE/BaseRepository.cs index e25db9f..e9afb1c 100644 --- a/Blog.Core.Repository/BASE/BaseRepository.cs +++ b/Blog.Core.Repository/BASE/BaseRepository.cs @@ -26,7 +26,7 @@ namespace Blog.Core.Repository.Base * 1、在appsettings.json 中开启MutiDBEnabled节点为true,必填 * 2、设置一个主连接的数据库ID,节点MainDB,对应的连接字符串的Enabled也必须true,必填 */ - if (Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + if (AppSettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) { //if (typeof(TEntity).GetTypeInfo().GetCustomAttributes(typeof(SugarTable), true).FirstOrDefault((x => x.GetType() == typeof(SugarTable))) is SugarTable sugarTable && !string.IsNullOrEmpty(sugarTable.TableDescription)) //{ diff --git a/Blog.Core.Repository/MongoRepository/MongoDbContext.cs b/Blog.Core.Repository/MongoRepository/MongoDbContext.cs index 29357fe..6eadedc 100644 --- a/Blog.Core.Repository/MongoRepository/MongoDbContext.cs +++ b/Blog.Core.Repository/MongoRepository/MongoDbContext.cs @@ -11,8 +11,8 @@ namespace Blog.Core.Repository.MongoRepository public MongoDbContext() { - var client = new MongoClient(Appsettings.app(new string[] { "Mongo", "ConnectionString" })); - _database = client.GetDatabase(Appsettings.app(new string[] { "Mongo", "Database" })); + var client = new MongoClient(AppSettings.app(new string[] { "Mongo", "ConnectionString" })); + _database = client.GetDatabase(AppSettings.app(new string[] { "Mongo", "Database" })); } public IMongoDatabase Db diff --git a/Blog.Core.Tests/DependencyInjection/DI_Test.cs b/Blog.Core.Tests/DependencyInjection/DI_Test.cs index c90461f..e921d80 100644 --- a/Blog.Core.Tests/DependencyInjection/DI_Test.cs +++ b/Blog.Core.Tests/DependencyInjection/DI_Test.cs @@ -60,7 +60,7 @@ namespace Blog.Core.Tests IServiceCollection services = new ServiceCollection(); services.AddAutoMapper(typeof(Startup)); - services.AddSingleton(new Appsettings(basePath)); + services.AddSingleton(new AppSettings(basePath)); services.AddSingleton(new LogLock(basePath)); services.AddScoped(); services.AddScoped(); @@ -79,8 +79,8 @@ namespace Blog.Core.Tests "/api/denied", permission, ClaimTypes.Role, - Appsettings.app(new string[] { "Audience", "Issuer" }), - Appsettings.app(new string[] { "Audience", "Audience" }), + AppSettings.app(new string[] { "Audience", "Issuer" }), + AppSettings.app(new string[] { "Audience", "Audience" }), signingCredentials,//签名凭据 expiration: TimeSpan.FromSeconds(60 * 60)//接口的过期时间 );