Пример #1
0
 /// <summary>
 /// 清空pattern树
 /// </summary>
 public void Clear()
 {
     Log.Print("module tree clear.");
     root = null;
     allNodesList.Clear();
     Map.Clear();
 }
Пример #2
0
        public string NodePath(string propertyName)
        {
            string  path = string.Empty;
            ObjNode node = GetNode(propertyName);

            path = node.PropertyName + "\\";
            for (int i = 0; i < node.Level; i++)
            {
                if (node.Parent != null)
                {
                    node = node.Parent;
                    path = node.PropertyName + "\\" + path;
                }
            }
            return(path);
        }
Пример #3
0
        /// <summary>
        /// 添加 RunnableModule,按照先访问根节点,再访问子节点顺序遍历添加
        /// </summary>
        public void AddProperty(string propertyName, string parentPropertyName, int level)
        {
            //Log.Print("AddModule Begine origin:" + module.Origin+ module.CommandsModule.Name);
            if (propertyName == null)
            {
                throw new Exception("module can not be null.");
            }
            if (root == null)
            {
                if (!String.IsNullOrEmpty(parentPropertyName))
                {
                    throw new Exception("Please add root node firstly.");
                }
                //Log.Print("Add root module");
                root = new ObjNode(null, propertyName, level);
                allNodesList.Add(root);
                Map.Add(propertyName, root);
                return;
            }
            // 子节点的parentModule不能为null
            if (String.IsNullOrEmpty(parentPropertyName))
            {
                throw new Exception("Parent of property  is null.");
            }
            ObjNode parentNode = GetNode(parentPropertyName);

            if (parentNode == null)
            {
                throw new Exception("Parent runnable module [" + parentNode.PropertyName + "] is not found in runnable module tree.");
            }
            ObjNode node = new ObjNode(parentNode, propertyName, level);

            parentNode.Children.Add(node);
            allNodesList.Add(node);
            Map.Add(propertyName, node);
            //Log.Print("AddModule Done:" + module.CommandsModule.Name);
        }
Пример #4
0
 public ObjNode(ObjNode parent, string propertyName, int level)
 {
     this.parent       = parent;
     this.PropertyName = propertyName;
     this.level        = level;
 }