This commit is contained in:
Fu Diwei 2022-05-01 22:08:32 +08:00
commit 6f1f7b8052
5 changed files with 24 additions and 24 deletions

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -17,21 +17,21 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Sample
{
services.AddControllers();
// 注入配置项(内容见 `appsettings.json` 文件)
// 注入配置项(内容见 `appsettings.json` 文件)
services.AddOptions();
services.Configure<Options.WechatOptions>(Configuration.GetSection(nameof(Options.WechatOptions)));
// 注入分布式锁
// 注入分布式锁
services.AddSingleton<Services.DistributedLock.IDistributedLockFactory, Services.DistributedLock.Implements.DistributedLockFactory>();
// 注入仓储类
// 注入仓储类
services.AddSingleton<Services.Repositories.IWechatAccessTokenEntityRepository, Services.Repositories.Implements.WechatAccessTokenEntityRepository>();
// 注入工厂 HTTP 客户端
// 注入工厂 HTTP 客户端
services.AddHttpClient();
services.AddSingleton<Services.HttpClients.IWechatApiHttpClientFactory, Services.HttpClients.Implements.WechatApiHttpClientFactory>();
// 注入后台任务
// 注入后台任务
services.AddHostedService<Services.BackgroundServices.WechatAccessTokenRefreshingBackgroundService>();
}

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -18,16 +18,16 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
{
services.AddControllers();
// 注入配置项(内容见 `appsettings.json` 文件)
// 注入配置项(内容见 `appsettings.json` 文件)
services.AddOptions();
services.Configure<Options.TenpayOptions>(Configuration.GetSection(nameof(Options.TenpayOptions)));
// 注入工厂 HTTP 客户端
// 注入工厂 HTTP 客户端
services.AddHttpClient();
services.AddSingleton<Services.HttpClients.IWechatTenpayCertificateManagerFactory, Services.HttpClients.Implements.WechatTenpayCertificateManagerFactory>();
services.AddSingleton<Services.HttpClients.IWechatTenpayHttpClientFactory, Services.HttpClients.Implements.WechatTenpayHttpClientFactory>();
// 注入后台任务
// 注入后台任务
services.AddHostedService<Services.BackgroundServices.TenpayCertificateRefreshingBackgroundService>();
}

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Information",
@ -12,10 +12,10 @@
"TenpayOptions": {
"Merchants": [
{
"MerchantId": "填写商户号",
"SecretV3": "填写商户 V3 API 密钥",
"CertSerialNumber": "填写商户证书序列号",
"CertPrivateKey": "填写商户证书文件内容"
"MerchantId": "填写商户号",
"SecretV3": "填写商户 V3 API 密钥",
"CertSerialNumber": "填写商户证书序列号",
"CertPrivateKey": "填写商户证书文件内容"
}
],
"NotifyUrl": "https://localhost:5001"

View File

@ -1,4 +1,4 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
{
public class WebApiApplication : HttpApplication
{
@ -6,22 +6,22 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
protected void Application_Start()
{
// 注册 WebAPI 区域
// 注册 WebAPI 区域
AreaRegistration.RegisterAllAreas();
// 注册 WebAPI 配置
// 注册 WebAPI 配置
GlobalConfiguration.Configure(WebApiConfiguration.Register);
// 注册全局过滤器
// 注册全局过滤器
FilterRegistration.RegisterGlobalFilters(GlobalFilters.Filters);
// 注册路由表
// 注册路由表
RouteRegistration.RegisterRoutes(RouteTable.Routes);
// 初始化 Autofac 依赖注入容器
// 初始化 Autofac 依赖注入容器
AutofacInitializer.Init();
// 初始化 Hangfire 定时任务
// 初始化 Hangfire 定时任务
_backgroundJobServer = HangfireInitializer.Init();
}

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Xunit;
@ -6,7 +6,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests
{
public class TestCase_JsonConverterTests
{
[Fact(DisplayName = "测试用例:自定义转换器之 `FlattenNArrayObjectConverterBase`")]
[Fact(DisplayName = "测试用例:自定义转换器之 `FlattenNArrayObjectConverterBase`")]
public void TestFlattenNArrayObjectConverter()
{
var newtonsoftJsonSerializer = new FlurlNewtonsoftJsonSerializer();