Beispiel #1
0
        /// <summary>
        /// 从xml文件中初始化对象
        /// </summary>
        public override void FromXML(XmlNode node)
        {
            this.DataState = DataState.UnChanged;
            this.Namespace = node.Attributes["namespace"].Value;
            this._guid = node.Attributes["Guid"].Value;
            this.ProjName = node.Attributes["Name"].Value;
            this.DataState = DataState.Update;

            this.EntityList.Clear();
            this.FloderList.Clear();
            this.DTOList.Clear();
            this.EnumList.Clear();
            this.RefrenceList.Clear();

            XmlNodeList nodeList = node.SelectNodes("RefrenceList/Refrence");
            if (nodeList != null)
            {
                foreach (XmlNode n in nodeList)
                {
                    ProjectRefrence projRef = new ProjectRefrence(this, string.Empty, string.Empty);
                    projRef.FromXML(n);
                    this.RefrenceList.Add(projRef);
                }
            }

            nodeList = node.SelectNodes("EntityList/Entity");
            //查找当前工程文件下所有的实体
            if (nodeList != null)
            {
                foreach (XmlNode n in nodeList)
                {
                    BEEntity entity = new BEEntity(this, string.Empty, string.Empty);
                    entity.FromXML(n);
                    this.EntityList.Add(entity);
                }
            }
            this.FloderList.AddRange(this.LoadFloderList(node));
            nodeList = node.SelectNodes("DTOList/DTO");
            if (nodeList != null)
            {
                foreach (XmlNode n in nodeList)
                {
                    DTOEntity dtoEntity = new DTOEntity(this, string.Empty, string.Empty);
                    dtoEntity.FromXML(n);
                    this.DTOList.Add(dtoEntity);
                }
            }
            nodeList = node.SelectNodes("EnumList/Enum");
            if (nodeList != null)
            {
                foreach (XmlNode n in nodeList)
                {
                    EnumEntity enumEntity = new EnumEntity(this, string.Empty, string.Empty);
                    enumEntity.FromXML(n);
                    this.EnumList.Add(enumEntity);
                }
            }

            this.IsChanged = false;
        }
        /// <summary>
        /// 新增实体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsm_AddEntity_Click(object sender, EventArgs e)
        {
            if (this._currentProjNode == null || this._currentProjNode.NodeType != NodeType.BEProj)
            {
                MessageBox.Show("请选择一个实体工程");
            }
            else
            {
                ComponentTreeNode tn = new ComponentTreeNode(NodeType.BEEntity, Guid.NewGuid().ToString());
                tn.Text = "新增实体";
                tn.ImageIndex = tn.SelectedImageIndex = 1;
                BEEntity entity = new BEEntity(this._currentProj as BEProj, tn.Guid, string.Empty);
                if (this._bindDataNode.NodeType == NodeType.Floder)
                {
                    entity.FloderGuid = this._bindDataNode.Guid;
                }
                entity.Code = string.Empty;
                entity.Name = string.Empty;
                entity.TableName = string.Empty;
                if (this._bindDataNode.NodeType == NodeType.Floder)
                {
                    entity.FloderGuid = this._bindDataNode.Guid;
                }

                this._currentProj.EntityList.Add(entity);

                this._bindDataNode.Nodes.Add(tn);

                this.groupBox3.Enabled = true;

                this.dataGridView1.Rows.Clear();

                this.tvProject.SelectedNode = tn;

            }
        }
 public BEColumn(string guid, BEProj proj, BEEntity entity)
     : base(guid)
 {
     this._guid = guid;
     this._proj = proj;
     this._entity = entity;
     this.DataState = DataState.Add;
 }
 public BuildEntity(BEEntity entity)
 {
     _entity = entity;
     _namespace = entity.Proj.Namespace;
 }
 public DTOEntity(BEEntity entity)
     : base(entity.Guid)
 {
     this.Code = entity.Code + AttrEndTag;
     this.Name = entity.Name;
     if (entity.InhertName == Attributes.BaseEntity)
     {
         this.InhertName = Attributes.BaseDTO;
     }
     else
     {
         this.InhertName = string.Empty;
         //如果实体继承一个类的话我们生成的dto也需要继承这个类生成的dto
         string[] namespaceArray = entity.InhertName.Split('.');
         int length = namespaceArray.Length;
         for (int i = 0; i < length - 2; i++)
         {
             this.InhertName += namespaceArray[i] + ".";
         }
         this.InhertName += namespaceArray[length - 2] + "." + DTOEntity.AssemblyEndTag + ".";
         this.InhertName += namespaceArray[length - 1] + DTOEntity.AttrEndTag;
         //this.InhertName = entity.Proj.Namespace + "." + DTOEntity.AssemblyEndTag + "." + entity.Code + DTOEntity.AttrEndTag;
     }
     this.InhertGuid = entity.InhertGuid;
     this._proj = entity.Proj;
     this._columnList.Clear();
     foreach (BEColumn col in entity.ColumnList)
     {
         DTOColumn dtoCol = new DTOColumn(this, col);
         this._columnList.Add(dtoCol);
     }
 }