From 981f86c7016490bcae622f11f4ac0eead378ff06 Mon Sep 17 00:00:00 2001 From: Loretta Date: Sat, 18 Oct 2025 08:43:57 +0200 Subject: [PATCH] improvements, fixes, etc... --- AyCode.Core/Extensions/PropertyHelper.cs | 1 + AyCode.Core/Extensions/SerializeObjectExtensions.cs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/AyCode.Core/Extensions/PropertyHelper.cs b/AyCode.Core/Extensions/PropertyHelper.cs index fe72497..e8eb83d 100644 --- a/AyCode.Core/Extensions/PropertyHelper.cs +++ b/AyCode.Core/Extensions/PropertyHelper.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Diagnostics.CodeAnalysis; using System.Reflection; namespace AyCode.Core.Extensions; diff --git a/AyCode.Core/Extensions/SerializeObjectExtensions.cs b/AyCode.Core/Extensions/SerializeObjectExtensions.cs index 5a8c610..92e05fb 100644 --- a/AyCode.Core/Extensions/SerializeObjectExtensions.cs +++ b/AyCode.Core/Extensions/SerializeObjectExtensions.cs @@ -1,4 +1,5 @@ -using System.Linq.Expressions; +using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; using AyCode.Core.Interfaces; using MessagePack.Resolvers; using MessagePack; @@ -41,6 +42,15 @@ public static class SerializeObjectExtensions return JsonConvert.DeserializeObject(json, toType, Options); } + /// + /// Using JSON + /// + /// + /// + /// + [return: NotNullIfNotNull(nameof(src))] + public static TDestination? CloneTo(this object? src) where TDestination : class => src?.ToJson().JsonTo(); + //public static string ToJson(this Expression source) => JsonConvert.SerializeObject(source, Options); public static byte[] ToMessagePack(this object message) => MessagePackSerializer.Serialize(message);