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