Пример #1
0
 private static ICollection<string> BuildColumnIndex(TableRuleConfig rule)
 {
     if (rule == null)
     {
         return new HashSet<string>();
     }
     var rs = rule.Rules;
     if (rs == null || rs.IsEmpty())
     {
         return new HashSet<string>();
     }
     var columnIndex = new HashSet<string>();
     foreach (var r in rs)
     {
         var columns = r.Columns;
         if (columns != null)
         {
             foreach (var col in columns)
             {
                 if (col != null)
                 {
                     columnIndex.Add(col.ToUpper());
                 }
             }
         }
     }
     return columnIndex;
 }
Пример #2
0
 public TableConfig(string name, string dataNode, TableRuleConfig rule, bool ruleRequired)
 {
     if (name == null)
     {
         throw new ArgumentException("table name is null");
     }
     Name = name.ToUpper();
     var dataNodes = SplitUtil.Split(dataNode, ',', '$', '-', '[', ']');
     if (dataNodes == null || dataNodes.Length <= 0)
     {
         throw new ArgumentException("invalid table dataNodes: " + dataNode);
     }
     DataNodes = dataNodes;
     Rule = rule;
     columnIndex = BuildColumnIndex(rule);
     IsRuleRequired = ruleRequired;
 }
Пример #3
0
        private void LoadTableRules(XmlElement root)
        {
            var list = root.GetElementsByTagName("tableRule");
            XmlNode node = null;
            XmlElement e = null;
            for (int i = 0, n = list.Count; i < n; i++)
            {
                node = list.Item(i);
                if (node.NodeType == XmlNodeType.Element)
                {
                    e = (XmlElement)node;
                    var name = e.GetAttribute("name");
                    if (tableRules.ContainsKey(name))
                    {
                        throw new ConfigException("table rule " + name + " duplicated!");
                    }

                    var ruleNodes = e.GetElementsByTagName("rule");
                    var length = ruleNodes.Count;
                    var ruleList = new List<RuleConfig>(length);
                    for (var j = 0; j < length; ++j)
                    {
                        var rule = LoadRule((XmlElement)ruleNodes.Item(j));
                        ruleList.Add(rule);
                        rules.Add(rule);
                    }
                    tableRules[name] = new TableRuleConfig(name, ruleList);
                }
            }
        }