16 lines
479 B
C#
16 lines
479 B
C#
using Newtonsoft.Json;
|
|
namespace LCU.Library.Internal.DispatcherModels.Helpers;
|
|
|
|
public static class Clone
|
|
{
|
|
public static T DeepClone<T>(this T source)
|
|
{
|
|
if (source is null)
|
|
{
|
|
return default;
|
|
}
|
|
|
|
var deserializeSettings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace };
|
|
return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(source), deserializeSettings);
|
|
}
|
|
} |