Esempio n. 1
0
        /// <summary>
        /// 配置公众号Sdk
        /// </summary>
        /// <param name="app"></param>
        /// <param name="setupAction"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseMPublicAccountSdk(this IApplicationBuilder app, Action <WxFuncs> setupAction = null)
        {
            WxFuncs funcs = app.ApplicationServices.GetRequiredService <WxFuncs>();

            setupAction?.Invoke(funcs);
            //如果没有设置获取微信配置逻辑,则自动从配置文件读取
            if (funcs.GetWeChatOptions == null)
            {
                IConfiguration        config       = app.ApplicationServices.GetRequiredService <IConfiguration>();
                IConfigurationSection wechatConfig = config.GetSection("Wx");
                if (wechatConfig != null)
                {
                    funcs.GetWeChatOptions = () => ConfigHelper.GetWeChatOptionsByConfiguration(config);
                }
            }
            return(app);
        }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="weChatFuncs"></param>
 /// <param name="serviceProvider"></param>
 public TokenManager(WxFuncs weChatFuncs, IServiceProvider serviceProvider)
 {
     this.weChatFuncs     = weChatFuncs;
     this.serviceProvider = serviceProvider;
 }