mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 18:04:42 +08:00
feat: 移除基础依赖库,升级公共组件,并适配 .NET 6.0
This commit is contained in:
@@ -34,7 +34,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".txt";
|
||||
|
||||
if (request.FileHash == null)
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Utilities.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (request.FileContentType == null)
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "text/plain";
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
|
||||
|
||||
if (request.FileHash == null)
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Utilities.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (request.FileContentType == null)
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
|
||||
|
||||
if (request.FileHash == null)
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Utilities.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (request.FileContentType == null)
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
|
||||
@@ -73,7 +73,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".mp4";
|
||||
|
||||
if (request.FileHash == null)
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Utilities.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (request.FileContentType == null)
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForVideo(request.FileName!) ?? "video/mp4";
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
|
||||
|
||||
if (request.FileHash == null)
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Utilities.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (request.FileContentType == null)
|
||||
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net461; netstandard2.0; net5.0</TargetFrameworks>
|
||||
<TargetFrameworks>net461; netstandard2.0; net5.0; net6.0</TargetFrameworks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||
@@ -27,12 +27,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.8.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SKIT.FlurlHttpClient.Wechat\SKIT.FlurlHttpClient.Wechat.csproj" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA-256 算法工具类。
|
||||
/// </summary>
|
||||
public static class SHA256Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取信息摘要。
|
||||
/// </summary>
|
||||
/// <param name="bytes">信息字节数组。</param>
|
||||
/// <returns>信息摘要。</returns>
|
||||
public static string Hash(byte[] bytes)
|
||||
{
|
||||
if (bytes == null) throw new ArgumentNullException(nameof(bytes));
|
||||
|
||||
using SHA256 sha = SHA256.Create();
|
||||
byte[] hashBytes = sha.ComputeHash(bytes);
|
||||
return BitConverter.ToString(hashBytes).Replace("-", "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取信息摘要。
|
||||
/// </summary>
|
||||
/// <param name="message">文本信息。</param>
|
||||
/// <returns>信息摘要。</returns>
|
||||
public static string Hash(string message)
|
||||
{
|
||||
if (message == null) throw new ArgumentNullException(nameof(message));
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(message);
|
||||
return Hash(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
using Flurl.Http.Configuration;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
/// <summary>
|
||||
/// 一个微信支付 API HTTP 客户端。
|
||||
/// </summary>
|
||||
public class WechatTenpayClient : CommonClientBase, IWechatClient
|
||||
public class WechatTenpayClient : CommonClientBase, ICommonClient
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的微信商户平台凭证。
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <summary>
|
||||
/// 表示微信支付 API 请求的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatTenpayRequest : IWechatRequest
|
||||
public abstract class WechatTenpayRequest : ICommonRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置请求超时时间(单位:毫秒)。如果不指定将使用构造 <see cref="WechatTenpayClient"/> 时的 <see cref="WechatTenpayClientOptions.Timeout"/> 参数,这在需要指定特定耗时请求(比如上传或下载文件)的超时时间时很有用。
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
/// <summary>
|
||||
/// 表示微信支付 API 响应的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatTenpayResponse : IWechatResponse
|
||||
public abstract class WechatTenpayResponse : ICommonResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取原始的 HTTP 响应状态码。
|
||||
|
||||
Reference in New Issue
Block a user