/// <summary> /// 对<see cref="WorkResult" />对象进行深拷贝,会同时拷贝附加内容 /// </summary> /// <param name="workResult"></param> /// <returns></returns> public static WorkResult DeepCopy(this WorkResult workResult) { var result = new WorkResult(); foreach (var propertyName in workResult.PropertyNameList) { if (workResult.GetProperty(propertyName, out object obj)) { result.SetProperty(propertyName, obj); } } return(result); }
/// <summary> /// 对泛型<see cref="WorkResult" />对象进行深拷贝,会同时拷贝附加内容 /// </summary> /// <param name="workResult"></param> /// <returns></returns> public static WorkResult <T> DeepCopy <T>(this WorkResult <T> workResult) { var result = new WorkResult <T> { Data = workResult.Data }; foreach (var propertyName in workResult.PropertyNameList) { if (workResult.GetProperty(propertyName, out object obj)) { result.SetProperty(propertyName, obj); } } return(result); }