diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServicesExtensions.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServiceCollectionExtensions.cs similarity index 98% rename from src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServicesExtensions.cs rename to src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServiceCollectionExtensions.cs index c91bcade..2f1d6dd4 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServicesExtensions.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServiceCollectionExtensions.cs @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.DependencyInjection; /// /// /// -public static class ServicesExtensions +public static class ServiceCollectionExtensions { /// /// diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/AdminService.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/Services/AdminService.cs similarity index 97% rename from src/blazor/admin/BootstrapAdmin.Web.Core/AdminService.cs rename to src/blazor/admin/BootstrapAdmin.Web.Core/Services/AdminService.cs index 4426b942..5aeee6ee 100644 --- a/src/blazor/admin/BootstrapAdmin.Web.Core/AdminService.cs +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/Services/AdminService.cs @@ -1,6 +1,6 @@ using Bootstrap.Security.Blazor; -namespace BootstrapAdmin.Web.Core; +namespace BootstrapAdmin.Web.Core.Services; /// /// diff --git a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ApplicationBuilderExtensions.cs b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ApplicationBuilderExtensions.cs index e128233a..b2a0fb90 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ApplicationBuilderExtensions.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ApplicationBuilderExtensions.cs @@ -1,24 +1,23 @@ -namespace BootstrapAdmin.Web.Extensions +namespace Microsoft.AspNetCore.Builder; + +/// +/// +/// +public static class ApplicationBuilderExtensions { /// /// /// - public static class ApplicationBuilderExtensions + /// + /// + public static WebApplication UseBootstrapBlazorAdmin(this WebApplication builder) { - /// - /// - /// - /// - /// - public static WebApplication UseBootstrapBlazorAdmin(this WebApplication builder) - { - // 开启健康检查 - builder.MapBootstrapHealthChecks(); + // 开启健康检查 + builder.MapBootstrapHealthChecks(); - builder.UseAuthentication(); - builder.UseAuthorization(); + builder.UseAuthentication(); + builder.UseAuthorization(); - return builder; - } + return builder; } } diff --git a/src/blazor/admin/BootstrapAdmin.Web/Extensions/CloudLoggerExtensions.cs b/src/blazor/admin/BootstrapAdmin.Web/Extensions/CloudLoggerExtensions.cs index e570de76..925128a4 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Extensions/CloudLoggerExtensions.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Extensions/CloudLoggerExtensions.cs @@ -2,84 +2,83 @@ using Microsoft.Extensions.Logging.Configuration; using Microsoft.Extensions.Options; -namespace BootstrapAdmin.Web.Extensions +namespace Microsoft.Extensions.DependencyInjection; + +/// +/// 邮件日志扩展方法 +/// +static class CloudLoggerExtensions { /// - /// 邮件日志扩展方法 + /// 注册邮件日志方法 /// - public static class CloudLoggerExtensions + /// + /// + public static ILoggingBuilder AddCloudLogger(this ILoggingBuilder builder) { - /// - /// 注册邮件日志方法 - /// - /// - /// - public static ILoggingBuilder AddCloudLogger(this ILoggingBuilder builder) - { - builder.Services.AddSingleton, LoggerProviderConfigureOptions>(); - builder.Services.AddSingleton, LoggerProviderOptionsChangeTokenSource>(); - builder.Services.AddSingleton(); - return builder; - } - } - - /// - /// 云日志提供类 - /// - [ProviderAlias("Cloud")] - public class CloudLoggerProvider : LoggerProvider - { - private readonly HttpClient httpClient; - private readonly IDisposable optionsReloadToken; - private CloudLoggerOption option; - - /// - /// 构造函数 - /// - public CloudLoggerProvider(IOptionsMonitor options) : base(null, new Func((name, logLevel) => logLevel >= LogLevel.Error)) - { - optionsReloadToken = options.OnChange(op => option = op); - option = options.CurrentValue; - - httpClient = new HttpClient - { - Timeout = TimeSpan.FromSeconds(10) - }; - httpClient.DefaultRequestHeaders.Connection.Add("keep-alive"); - - LogCallback = new Action(async message => - { - if (!string.IsNullOrEmpty(option.Url)) - { - try { await httpClient.PostAsJsonAsync(option.Url, message); } - catch { } - } - }); - } - - /// - /// - /// - /// - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing) - { - httpClient.Dispose(); - optionsReloadToken.Dispose(); - } - } - } - - /// - /// 云日志配置类 - /// - public class CloudLoggerOption - { - /// - /// 获得/设置 云日志地址 - /// - public string Url { get; set; } = ""; + builder.Services.AddSingleton, LoggerProviderConfigureOptions>(); + builder.Services.AddSingleton, LoggerProviderOptionsChangeTokenSource>(); + builder.Services.AddSingleton(); + return builder; } } + +/// +/// 云日志提供类 +/// +[ProviderAlias("Cloud")] +class CloudLoggerProvider : LoggerProvider +{ + private readonly HttpClient httpClient; + private readonly IDisposable optionsReloadToken; + private CloudLoggerOption option; + + /// + /// 构造函数 + /// + public CloudLoggerProvider(IOptionsMonitor options) : base(null, new Func((name, logLevel) => logLevel >= LogLevel.Error)) + { + optionsReloadToken = options.OnChange(op => option = op); + option = options.CurrentValue; + + httpClient = new HttpClient + { + Timeout = TimeSpan.FromSeconds(10) + }; + httpClient.DefaultRequestHeaders.Connection.Add("keep-alive"); + + LogCallback = new Action(async message => + { + if (!string.IsNullOrEmpty(option.Url)) + { + try { await httpClient.PostAsJsonAsync(option.Url, message); } + catch { } + } + }); + } + + /// + /// + /// + /// + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (disposing) + { + httpClient.Dispose(); + optionsReloadToken.Dispose(); + } + } +} + +/// +/// 云日志配置类 +/// +class CloudLoggerOption +{ + /// + /// 获得/设置 云日志地址 + /// + public string Url { get; set; } = ""; +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServicesExtensions.cs b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs similarity index 94% rename from src/blazor/admin/BootstrapAdmin.Web/Extensions/ServicesExtensions.cs rename to src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs index 4e87f52c..89374a31 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServicesExtensions.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs @@ -1,16 +1,16 @@ -using BootstrapAdmin.Web.Core; +using BootstrapAdmin.Web.Core.Services; using BootstrapAdmin.Web.HealthChecks; using BootstrapAdmin.Web.Services; using BootstrapAdmin.Web.Services.SMS; using BootstrapAdmin.Web.Services.SMS.Tencent; using BootstrapAdmin.Web.Utils; -namespace BootstrapAdmin.Web.Extensions +namespace Microsoft.Extensions.DependencyInjection { /// /// /// - public static class ServicesExtensions + public static class ServiceCollectionExtensions { /// /// 添加示例后台任务