From 0b3299f091931ece668ebfb761898664dbb02961 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Tue, 19 Oct 2021 10:51:08 +0800 Subject: [PATCH] style: clean code --- .../Utilities/Internal/XmlUtility.cs | 6 +++--- .../Utilities/Internal/XmlUtility.cs | 6 +++--- .../Utilities/Internal/XmlUtility.cs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Utilities/Internal/XmlUtility.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Utilities/Internal/XmlUtility.cs index 57a6bd4f..8cd97d73 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Utilities/Internal/XmlUtility.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Utilities/Internal/XmlUtility.cs @@ -17,8 +17,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Utilities { if (type == null) throw new ArgumentNullException(nameof(type)); - string skey = type.AssemblyQualifiedName; - XmlSerializer? xmlSerializer = (XmlSerializer)_serializers[skey]; + string skey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString(); + XmlSerializer? xmlSerializer = (XmlSerializer?)_serializers[skey]; if (xmlSerializer == null) { xmlSerializer = new XmlSerializer(type, new XmlRootAttribute("xml")); @@ -63,7 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Utilities { using var reader = new StringReader(xml); XmlSerializer serializer = GetTypedSerializer(type); - return serializer.Deserialize(reader); + return serializer.Deserialize(reader)!; } public static T Deserialize(string xml) diff --git a/src/SKIT.FlurlHttpClient.Wechat.OpenAI/Utilities/Internal/XmlUtility.cs b/src/SKIT.FlurlHttpClient.Wechat.OpenAI/Utilities/Internal/XmlUtility.cs index 38d62f3c..4d305cc9 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.OpenAI/Utilities/Internal/XmlUtility.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.OpenAI/Utilities/Internal/XmlUtility.cs @@ -17,8 +17,8 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities { if (type == null) throw new ArgumentNullException(nameof(type)); - string skey = type.AssemblyQualifiedName; - XmlSerializer? xmlSerializer = (XmlSerializer)_serializers[skey]; + string skey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString(); + XmlSerializer? xmlSerializer = (XmlSerializer?)_serializers[skey]; if (xmlSerializer == null) { xmlSerializer = new XmlSerializer(type, new XmlRootAttribute("xml")); @@ -63,7 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities { using var reader = new StringReader(xml); XmlSerializer serializer = GetTypedSerializer(type); - return serializer.Deserialize(reader); + return serializer.Deserialize(reader)!; } public static T Deserialize(string xml) diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Utilities/Internal/XmlUtility.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Utilities/Internal/XmlUtility.cs index 1260d779..0b331691 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Utilities/Internal/XmlUtility.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Utilities/Internal/XmlUtility.cs @@ -17,8 +17,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Utilities { if (type == null) throw new ArgumentNullException(nameof(type)); - string skey = type.AssemblyQualifiedName; - XmlSerializer? xmlSerializer = (XmlSerializer)_serializers[skey]; + string skey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString(); + XmlSerializer? xmlSerializer = (XmlSerializer?)_serializers[skey]; if (xmlSerializer == null) { xmlSerializer = new XmlSerializer(type, new XmlRootAttribute("xml")); @@ -63,7 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Utilities { using var reader = new StringReader(xml); XmlSerializer serializer = GetTypedSerializer(type); - return serializer.Deserialize(reader); + return serializer.Deserialize(reader)!; } public static T Deserialize(string xml)