PropertiesExtended.cs 722 B

123456789101112131415161718192021222324252627
  1. namespace WWPipeLine.Commons
  2. {
  3. /// <summary>
  4. /// 类的扩展属性
  5. /// </summary>
  6. public static class PropertiesExtended
  7. {
  8. /// <summary>
  9. /// 实现类的深拷贝
  10. /// </summary>
  11. /// <typeparam name="T"></typeparam>
  12. /// <param name="obj"></param>
  13. /// <returns></returns>
  14. #region
  15. public static T DataDeepClone<T>(this object obj) where T : class
  16. {
  17. T result = (T)obj;
  18. string json = Commons.SerializeHelper.JsonHepler.Json_SerializeObject(obj, true);
  19. result = Commons.SerializeHelper.JsonHepler.Json_DeserializeObject<T>(json);
  20. return result;
  21. }
  22. #endregion
  23. }
  24. }