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);

                }
            }
  • 相关阅读:
    kibana.yml(中文配置详解)
    Elasticsearch之marvel(集群管理、监控)插件安装之后的浏览详解
    ElasticSearch vs Lucene多维度分析对比
    ElasticSearch 应用场景
    ElasticSearch 在Hadoop生态圈的位置
    ElasticSearch 工作原理
    ElasticSearch 架构图
    ElasticSearch vs 关系型数据库
    Codeforces Round #311 (Div. 2)
    uva 568(数学)
  • 原文地址:https://www.cnblogs.com/ronphy/p/2443460.html
Copyright © 2011-2022 走看看