31 lines
747 B
C#
31 lines
747 B
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace JSMachine.WMS.Infrastructure.Helper
|
|
{
|
|
/// <summary>
|
|
/// 对象拷贝帮助类
|
|
/// </summary>
|
|
public static class ObjectCloneHelper
|
|
{
|
|
/// <summary>
|
|
/// 深拷贝
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <param name="t"></param>
|
|
/// <returns></returns>
|
|
public static T DeepClone<T>(T t) where T : class
|
|
{
|
|
if (t == null)
|
|
return null;
|
|
|
|
string json = JsonConvert.SerializeObject(t);
|
|
return JsonConvert.DeserializeObject<T>(json);
|
|
}
|
|
}
|
|
}
|