improvements, fixes, etc...

This commit is contained in:
Loretta 2025-10-18 08:43:57 +02:00
parent f26f04eec5
commit 981f86c701
2 changed files with 12 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
namespace AyCode.Core.Extensions;

View File

@ -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);
}
/// <summary>
/// Using JSON
/// </summary>
/// <typeparam name="TDestination"></typeparam>
/// <param name="src"></param>
/// <returns></returns>
[return: NotNullIfNotNull(nameof(src))]
public static TDestination? CloneTo<TDestination>(this object? src) where TDestination : class => src?.ToJson().JsonTo<TDestination>();
//public static string ToJson(this Expression source) => JsonConvert.SerializeObject(source, Options);
public static byte[] ToMessagePack(this object message) => MessagePackSerializer.Serialize(message);