From 54ed427750221326d14a9debbcf02ba47882abed Mon Sep 17 00:00:00 2001 From: JeffreySu Date: Wed, 26 Jun 2024 00:39:37 +0800 Subject: [PATCH] =?UTF-8?q?Weixin.All=20v2024.6.26.1=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B3=A8=E5=86=8C=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GlobalUsing.cs | 1 + .../Program.cs | 11 +++++---- .../Senparc.Weixin.Sample.MP.Simple.csproj | 2 +- .../Senparc.Weixin.Sample.MP.csproj | 8 +++---- .../Senparc.Weixin.All.csproj | 2 +- src/Senparc.Weixin.All/WeixinEntensions.cs | 24 +++++++++++++++++++ 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/GlobalUsing.cs b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/GlobalUsing.cs index 4da639697a..e11af54c7f 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/GlobalUsing.cs +++ b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/GlobalUsing.cs @@ -6,4 +6,5 @@ global using Senparc.Weixin.Sample.MP; global using Microsoft.Extensions.Options; global using Senparc.Weixin.Entities; +global using Senparc.Weixin.All; global using Microsoft.Extensions.FileProviders; diff --git a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Program.cs b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Program.cs index e25c6846d6..c6d5fe1bea 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Program.cs +++ b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Program.cs @@ -19,11 +19,12 @@ //启用微信配置(必须) var registerService = app.UseSenparcWeixin(app.Environment, - null /* 不为 null 则覆盖 appsettings 中的 SenpacSetting 配置*/, - null /* 不为 null 则覆盖 appsettings 中的 SenpacWeixinSetting 配置*/, - register => { /* CO2NET 全局配置 */ }, - (register, weixinSetting) => {/* 注册公众号或其他平台信息(可以执行多次,注册多个公众号)*/}, - true); + senparcSetting: null /* 不为 null 则覆盖 appsettings 中的 SenpacSetting 配置*/, + senparcWeixinSetting: null /* 不为 null 则覆盖 appsettings 中的 SenpacWeixinSetting 配置*/, + globalRegisterConfigure: register => { /* CO2NET 全局配置 */ }, + weixinRegisterConfigure: (register, weixinSetting) => {/* 注册公众号或其他平台信息(可以执行多次,注册多个公众号)*/}, + autoRegisterAllPlatforms: true /* 自动注册所有平台 */ + ); #region 使用 MessageHadler 中间件,用于取代创建独立的 Controller diff --git a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Senparc.Weixin.Sample.MP.Simple.csproj b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Senparc.Weixin.Sample.MP.Simple.csproj index ae5b04dba3..a01355fd89 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Senparc.Weixin.Sample.MP.Simple.csproj +++ b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Senparc.Weixin.Sample.MP.Simple.csproj @@ -20,7 +20,7 @@ - + diff --git a/Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.csproj b/Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.csproj index 7923b5bf82..3352801082 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.csproj +++ b/Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.csproj @@ -24,10 +24,10 @@ - - - - + + + + diff --git a/src/Senparc.Weixin.All/Senparc.Weixin.All.csproj b/src/Senparc.Weixin.All/Senparc.Weixin.All.csproj index 596adebf5b..9cc796e802 100644 --- a/src/Senparc.Weixin.All/Senparc.Weixin.All.csproj +++ b/src/Senparc.Weixin.All/Senparc.Weixin.All.csproj @@ -3,7 +3,7 @@ net8.0 enable enable - 2024.6.26 + 2024.6.26.1 10.0 Senparc.Weixin.All Senparc.Weixin.All diff --git a/src/Senparc.Weixin.All/WeixinEntensions.cs b/src/Senparc.Weixin.All/WeixinEntensions.cs index 60bd781bb3..7f7ed7cb77 100644 --- a/src/Senparc.Weixin.All/WeixinEntensions.cs +++ b/src/Senparc.Weixin.All/WeixinEntensions.cs @@ -14,6 +14,9 @@ using Senparc.Weixin.TenPayV3; using Senparc.CO2NET; using Senparc.CO2NET.Extensions; +using Microsoft.AspNetCore.Builder; +using Senparc.CO2NET.Cache; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Senparc.Weixin.All @@ -52,6 +55,27 @@ public static IRegisterService UseSenparcWeixin(this IRegisterService registerSe return registerService; } + public static IRegisterService UseSenparcWeixin(this IApplicationBuilder app, + Microsoft.Extensions.Hosting.IHostEnvironment/*IHostingEnvironment*/ env, + SenparcSetting senparcSetting, SenparcWeixinSetting senparcWeixinSetting, + Action globalRegisterConfigure, + Action weixinRegisterConfigure, + bool autoRegisterAllPlatforms, + + //CO2NET 鍏ㄥ眬璁剧疆 + bool autoScanExtensionCacheStrategies = false, + Func> extensionCacheStrategiesFunc = null + ) + { + //杩涜鍏ㄥ眬娉ㄥ唽 + var registerService = app.UseSenparcWeixin(env, senparcSetting, senparcWeixinSetting, globalRegisterConfigure, weixinRegisterConfigure, autoRegisterAllPlatforms, autoScanExtensionCacheStrategies); + + //杩涜鑷姩娉ㄥ唽 + registerService.UseSenparcWeixin(senparcWeixinSetting, weixinRegisterConfigure, autoRegisterAllPlatforms); + + return registerService; + } + /// /// 鏄惁宸茬粡璁剧疆涓烘湁鏁堢殑鍙傛暟 ///