From 44e1c009e326a40e33a28fb5d851d7a4a4258d65 Mon Sep 17 00:00:00 2001 From: wangjun Date: Fri, 21 Jul 2023 21:50:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4AbpProJsonSerializer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Lion/AbpPro/CAP/AbpProJsonSerializer.cs | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 aspnet-core/frameworks/src/Lion.AbpPro.CAP/Lion/AbpPro/CAP/AbpProJsonSerializer.cs diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.CAP/Lion/AbpPro/CAP/AbpProJsonSerializer.cs b/aspnet-core/frameworks/src/Lion.AbpPro.CAP/Lion/AbpPro/CAP/AbpProJsonSerializer.cs deleted file mode 100644 index e7c4e2661..000000000 --- a/aspnet-core/frameworks/src/Lion.AbpPro.CAP/Lion/AbpPro/CAP/AbpProJsonSerializer.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace Lion.AbpPro.CAP; - -public class AbpProJsonSerializer : ISerializer, ISingletonDependency -{ - private readonly IJsonSerializer _jsonSerializer; - - public AbpProJsonSerializer(IJsonSerializer jsonSerializer) - { - _jsonSerializer = jsonSerializer; - } - - public virtual string Serialize(Message message) - { - return _jsonSerializer.Serialize(message); - } - - public virtual ValueTask SerializeAsync(Message message) - { - if (message == null) - { - throw new ArgumentNullException(nameof(message)); - } - - if (message.Value == null) - { - return new ValueTask(new TransportMessage(message.Headers, null)); - } - - var json = _jsonSerializer.Serialize(message.Value); - - return new ValueTask(new TransportMessage(message.Headers, Encoding.UTF8.GetBytes(json))); - } - - public virtual Message Deserialize(string json) - { - return _jsonSerializer.Deserialize(json); - } - - public virtual ValueTask DeserializeAsync(TransportMessage transportMessage, Type valueType) - { - if (valueType == null || transportMessage.Body.IsEmpty) - { - return new ValueTask(new Message(transportMessage.Headers, null)); - } - - var json = Encoding.UTF8.GetString(transportMessage.Body.ToArray()); - - return new ValueTask(new Message(transportMessage.Headers, - _jsonSerializer.Deserialize(valueType, json))); - } - - public virtual object Deserialize(object value, Type valueType) - { - return _jsonSerializer.Deserialize(valueType, value.ToString()); - } - - public virtual bool IsJsonType(object jsonObject) - { - return jsonObject is JsonElement; - } -} \ No newline at end of file