zoukankan      html  css  js  c++  java
  • DTO的深度克隆实现

                   

     /// <summary>
            
    /// 克隆方法
            
    /// </summary>
            
    /// <returns></returns>
            public object Clone()
            {
                try
                {

                    Type type = this.GetType();

                    VoucherDTO vd = (VoucherDTO)Activator.CreateInstance(type);

                    PropertyInfo[] pilist = type.GetProperties();

                    foreach (PropertyInfo item in pilist)
                    {
                        PropertyInfo pi = this.GetType().GetProperty(item.Name);

                        if (pi != null)
                        {
                            object value = pi.GetValue(thisnull);

                            item.SetValue(vd, value, null);
                        }
                    }

                    vd.Details = new List<VoucherDTO>();

                    return vd;
                }
                catch (Exception ex)
                {
                    throw new Exception("克隆方法出现异常!", ex);

                }
            }
  • 相关阅读:
    回归测试
    系统测试
    单元测试
    软件测试规律之木桶原理
    集成测试
    软件测试度量
    测试用例设计方法之错误推测法
    测试用例设计方法之因果图方法
    有趣的算法:1元=1分
    【转】 arcServer 一些 FAQ
  • 原文地址:https://www.cnblogs.com/ronphy/p/2443460.html
Copyright © 2011-2022 走看看