chore(tenpayv3): 新增基于 .NET Framework 4.7 的示例项目

This commit is contained in:
Fu Diwei
2021-12-28 14:05:39 +08:00
parent b2ce287136
commit 2dcfcab262
58 changed files with 1114 additions and 204 deletions

View File

@@ -6,11 +6,12 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using SKIT.FlurlHttpClient.Wechat.Api;
using SKIT.FlurlHttpClient.Wechat.Api.Models;
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.BackgroundServices
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample.Services.BackgroundServices
{
using SKIT.FlurlHttpClient.Wechat.Api;
using SKIT.FlurlHttpClient.Wechat.Api.Models;
class WechatAccessTokenRefreshingBackgroundService : BackgroundService
{
private readonly ILogger _logger;

View File

@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Medallion.Threading;
using Medallion.Threading;
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.DistributedLock
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample.Services.DistributedLock
{
public interface IDistributedLockFactory
{

View File

@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Medallion.Threading;
using Medallion.Threading.FileSystem;
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.DistributedLock.Implements
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample.Services.DistributedLock.Implements
{
class DistributedLockFactory : IDistributedLockFactory
{
@@ -14,7 +11,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.DistributedLock.I
public IDistributedLock Create(string lockName)
{
// NOTICE: 单机演示基于文件实现分布式锁,生产项目请替换成其他实现
// NOTICE:
// 单机演示基于文件实现分布式锁,生产项目请替换成其他实现。
return new FileDistributedLock(_lockFileDirectory, lockName);
}
}

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.HttpClients
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample.Services.HttpClients
{
public interface IWechatApiHttpClientFactory
{

View File

@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
using Flurl.Http.Configuration;
using Microsoft.Extensions.Options;
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.HttpClients.Implements
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample.Services.HttpClients.Implements
{
partial class WechatApiHttpClientFactory : IWechatApiHttpClientFactory
{
@@ -26,6 +24,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.HttpClients.Imple
public WechatApiClient Create(string appId)
{
// NOTICE:
// 这里的工厂方法是为了演示多租户而存在的,可根据 AppId 生成不同的 API 客户端。
// 如果你的项目只存在唯一一个租户,那么直接注入 `WechatApiClient` 即可。
var wechatAccountOptions = _wechatOptions.Accounts?.FirstOrDefault(e => string.Equals(appId, e.AppId));
if (wechatAccountOptions == null)
throw new Exception("未在配置项中找到该 AppId 对应的微信账号。");

View File

@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.Repositories
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample.Services.Repositories
{
public interface IWechatAccessTokenEntityRepository : IEnumerable<Models.WechatAccessTokenEntity>
{

View File

@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NMemory;
using NMemory;
using NMemory.Tables;
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.Repositories.Implements
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample.Services.Repositories.Implements
{
internal class GlobalDatabase
{

View File

@@ -1,10 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Services.Repositories.Implements
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample.Services.Repositories.Implements
{
public class WechatAccessTokenEntityRepository : IWechatAccessTokenEntityRepository
{