//初始化实体对象 private void AddEnities(string fullName) { xml = new MyXML(fullName); XmlNodeList tables = xml.GetNodes("Config/Table"); Entity entity = null; Property property = null; bool t = true; bool r=true; int i = 0; foreach (XmlNode table in tables) { entity = new Entity(xml.GetNodeAttribute(table,"Name")); r = bool.TryParse(xml.GetNodeAttribute(table, "DeleteRepeat"),out t); if (r) { entity.DeleteRepeat = Convert.ToBoolean(xml.GetNodeAttribute(table, "DeleteRepeat")); } if (xml.GetFirstChildNode(table) != null)//说明有列配置 { foreach (XmlNode column in xml.GetChildNodes(table)) { property = new Property(); r = bool.TryParse(xml.GetNodeAttribute(column, "IsPrimaryKey"), out t); if (r) { property.IsPrimaryKey = Convert.ToBoolean(xml.GetNodeAttribute(column, "IsPrimaryKey")); } property.ColumnName = xml.GetNodeAttribute(column, "ColumnName"); if (xml.GetNodeAttribute(column, "HeaderText") != "") { property.HeaderText = xml.GetNodeAttribute(column, "HeaderText"); } r = bool.TryParse(xml.GetNodeAttribute(column, "Required"), out t); if (r) { property.Required = Convert.ToBoolean(xml.GetNodeAttribute(column, "Required")); } property.DataType = xml.GetNodeAttribute(column, "DataType") != "" ? xml.GetNodeAttribute(column, "DataType") : "string"; if (xml.GetNodeAttribute(column, "DataLength") != "") { r = int.TryParse(xml.GetNodeAttribute(column, "DataLength"),out i); if (r) { property.DataLength = i; } } property.Comment = xml.GetNodeAttribute(column, "Comment"); property.DefaultValue = xml.GetNodeAttribute(column, "DefaultValue") != "" ? xml.GetNodeAttribute(column, "DefaultValue") : ""; if (xml.GetFirstChildNode(column) != null)//说明有代码表 { DictionaryEntity dictionaryEntity = new DictionaryEntity(); dictionaryEntity.Name = xml.GetNodeAttribute(xml.GetFirstChildNode(column), "Name"); dictionaryEntity.PrimaryKey = xml.GetNodeAttribute(xml.GetFirstChildNode(column), "PrimaryKey"); dictionaryEntity.ReferenceColumn = xml.GetNodeAttribute(xml.GetFirstChildNode(column), "ReferenceColumn"); dictionaryEntity.Condition = xml.GetNodeAttribute(xml.GetFirstChildNode(column), "Condition"); property.CodeTable = dictionaryEntity; } entity.Propertys.Add(property); } entities.Add(entity); } else { string excludedColumns = xml.GetNodeAttribute(table, "ExcludedColumns"); if (excludedColumns != "") { foreach (string ec in excludedColumns.Split(',')) { entity.ExcludedColumns.Add(ec); } } entities.Add(entity); } } }