Beispiel #1
0
 /// <summary>
 /// 获取或快速创建一个字段配置
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public TableField this[string name] {
     get {
         // 从已有的平台配置中查找
         for (int i = 0; i < this.Fields.Count; i++)
         {
             if (this.Fields[i].Name == name)
             {
                 return(this.Fields[i]);
             }
         }
         // 添加一个新的平台配置
         TableField field = new TableField();
         field.Name = name;
         this.Fields.Add(field);
         return(field);
     }
 }
Beispiel #2
0
        /// <summary>
        /// 对象实例化
        /// </summary>
        /// <param name="xml"></param>
        public Table(string xml = null)
        {
            this.Fields = new List <TableField>();
            if (!xml.IsNoneOrNull())
            {
                using (var doc = dpz3.Xml.Parser.GetDocument(xml)) {
                    // 读取数据库设置
                    var table = doc["table"];
                    this.FillData(table);

                    // 读取平台信息
                    var fields = table.GetNodesByTagName("field", false);
                    foreach (var field in fields)
                    {
                        // 添加平台信息
                        TableField tableField = new TableField();
                        this.Fields.Add(tableField);

                        // 设置平台信息
                        tableField.FillData(field);
                    }
                }
            }
        }