diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventSerializationExtensions.cs
similarity index 84%
rename from src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventExtensions.cs
rename to src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventSerializationExtensions.cs
index 41b33339..6f637353 100644
--- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventExtensions.cs
+++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientEventSerializationExtensions.cs
@@ -9,9 +9,9 @@ using System.Xml.Serialization;
namespace SKIT.FlurlHttpClient.Wechat.Api
{
///
- /// 为 提供回调通知事件的扩展方法。
+ /// 为 提供回调通知事件序列化的扩展方法。
///
- public static class WechatApiClientEventExtensions
+ public static class WechatApiClientEventSerializationExtensions
{
private class EncryptedWechatApiEvent
{
@@ -33,15 +33,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
public string Signature { get; set; } = default!;
}
- ///
- /// 从 JSON 反序列化得到 对象。
- ///
- ///
- ///
- /// 是否是安全模式(即是否需要解密)。
- ///
- public static TEvent DeserializeEventFromJson(this WechatApiClient client, string callbackJson, bool safety = false)
- where TEvent : WechatApiEvent, WechatApiEvent.Types.IJsonSerializable, new()
+ private static TEvent InnerDeserializeEventFromJson(this WechatApiClient client, string callbackJson, bool safety)
+ where TEvent : WechatApiEvent
{
if (client == null) throw new ArgumentNullException(nameof(client));
if (string.IsNullOrEmpty(callbackJson)) throw new ArgumentNullException(callbackJson);
@@ -58,8 +51,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
throw new Exceptions.WechatApiEventSerializationException("Encrypt event failed, because of empty encrypted data.");
callbackJson = Utilities.WxBizMsgCryptor.AESDecrypt(
- cipherText: encryptedEvent.EncryptedData,
- encodingAESKey: client.Credentials.PushEncodingAESKey!,
+ cipherText: encryptedEvent.EncryptedData,
+ encodingAESKey: client.Credentials.PushEncodingAESKey!,
out _
);
}
@@ -76,15 +69,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
}
}
- ///
- /// 从 XML 反序列化得到 对象。
- ///
- ///
- ///
- /// 是否是安全模式(即是否需要解密)。
- ///
- public static TEvent DeserializeEventFromXml(this WechatApiClient client, string callbackXml, bool safety = false)
- where TEvent : WechatApiEvent, WechatApiEvent.Types.IXmlSerializable, new()
+ private static TEvent InnerDeserializeEventFromXml(this WechatApiClient client, string callbackXml, bool safety)
+ where TEvent : WechatApiEvent
{
if (client == null) throw new ArgumentNullException(nameof(client));
if (string.IsNullOrEmpty(callbackXml)) throw new ArgumentNullException(callbackXml);
@@ -112,6 +98,58 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
}
}
+ ///
+ /// 从 JSON 反序列化得到 对象。
+ ///
+ ///
+ ///
+ ///
+ /// 是否是安全模式(即是否需要解密)。
+ ///
+ public static TEvent DeserializeEventFromJson(this WechatApiClient client, string callbackJson, bool safety = false)
+ where TEvent : WechatApiEvent, WechatApiEvent.Types.IJsonSerializable, new()
+ {
+ return InnerDeserializeEventFromJson(client, callbackJson, safety);
+ }
+
+ ///
+ /// 从 JSON 反序列化得到 对象。
+ ///
+ ///
+ ///
+ /// 是否是安全模式(即是否需要解密)。
+ ///
+ public static WechatApiEvent DeserializeEventFromJson(this WechatApiClient client, string callbackJson, bool safety = false)
+ {
+ return InnerDeserializeEventFromJson(client, callbackJson, safety);
+ }
+
+ ///
+ /// 从 XML 反序列化得到 对象。
+ ///
+ ///
+ ///
+ ///
+ /// 是否是安全模式(即是否需要解密)。
+ ///
+ public static TEvent DeserializeEventFromXml(this WechatApiClient client, string callbackXml, bool safety = false)
+ where TEvent : WechatApiEvent, WechatApiEvent.Types.IXmlSerializable, new()
+ {
+ return InnerDeserializeEventFromXml(client, callbackXml, safety);
+ }
+
+ ///
+ /// 从 XML 反序列化得到 对象。
+ ///
+ ///
+ ///
+ /// 是否是安全模式(即是否需要解密)。
+ ///
+ public static WechatApiEvent DeserializeEventFromXml(this WechatApiClient client, string callbackXml, bool safety = false)
+ {
+ return InnerDeserializeEventFromXml(client, callbackXml, safety);
+ }
+
///
/// 将 对象序列化成 JSON。
///