Com.Aote.ObjectTools.GeneralObject.CopyFrom C# (CSharp) Method

CopyFrom() public method

public CopyFrom ( GeneralObject go ) : void
go GeneralObject
return void
        public void CopyFrom(GeneralObject go)
        {
            //复制实体类型
            if (go.entityType != null)
            {
                EntityType = go.EntityType;
            }
            foreach (string key in go._customPropertyValues.Keys)
            {
                object value = go._customPropertyValues[key];
                //是列表,进行列表复制
                if (value is BaseObjectList)
                {
                    //如果列表不存在,新建列表
                    if (!_customPropertyValues.ContainsKey(key) ||  _customPropertyValues[key] == null)
                    {
                        ObjectList ol = new ObjectList();
                        SetPropertyValue(key, ol, true);
                    }
                   
                        ObjectList nol = (ObjectList)_customPropertyValues[key];
                        nol.CopyFrom(value as BaseObjectList);
                  
                 
                }
                //是对象,进行对象复制
                else if (value is GeneralObject)
                {
                    SetPropertyValue(key, value, true);
                    ////对象不存在,新建对象
                    //if (!_customPropertyValues.ContainsKey(key) || _customPropertyValues[key] == null)
                    //{
                    //    GeneralObject obj = new GeneralObject();
                    //    SetPropertyValue(key, obj, true);
                    //}
                    ////进行对象复制
                    //GeneralObject ngo = (GeneralObject)_customPropertyValues[key];
                    //ngo.CopyFrom((GeneralObject)value);
                }
                //是一般属性,调用设置属性值的过程
                else
                {
                    this.NewGetType();
                    SetPropertyValue(key, value, true);
                }
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// 复制自己
        /// </summary>
        /// <returns>复制结果</returns>
        public GeneralObject Clone()
        {
            GeneralObject go = new GeneralObject();

            go.CopyFrom(this);
            return(go);
        }
All Usage Examples Of Com.Aote.ObjectTools.GeneralObject::CopyFrom