using HZY.Framework.Core.AspNetCore; using MiaoYu.Core.Cos.Configs; using MiaoYu.Core.Cos.Services; using MiaoYu.Core.Cos.Services.Impl; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MiaoYu.Core.Cos { /// /// cos /// public class CoreCosStartup : StartupModule { /// /// 服务配置 /// /// public override void ConfigureServices(WebApplicationBuilder webApplicationBuilder) { var tencentConfig = webApplicationBuilder.Configuration.GetSection("TencentCloud").Get(); if (tencentConfig == null) { tencentConfig = new TencentConfig(); } if (tencentConfig.CosConfig == null) { tencentConfig.CosConfig = new TencentCosConfig() { }; } if (string.IsNullOrEmpty(tencentConfig.CosConfig.SecretId)) { tencentConfig.CosConfig.SecretId = tencentConfig.SecretId; } if (string.IsNullOrEmpty(tencentConfig.CosConfig.SecretKey)) { tencentConfig.CosConfig.SecretKey = tencentConfig.SecretKey; } //注册一个验证码的服务 webApplicationBuilder.Services.AddSingleton(tencentConfig); //webApplicationBuilder.Services.AddScoped(); } /// /// 使用服务 /// /// public override void Configure(WebApplication webApplication) { } } }