first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user