Example #1
0
        public FuncTreeNode AddNodes(string xpath)
        {
            string[] paths = xpath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            if (paths.Length == 0)
            {
                throw new Exception("Unable to add the root node");
            }
            int          index = 0;
            FuncTreeNode tmp   = this;

            while (index < paths.Length)
            {
                string tmpNodeName = paths[index];
                if (!tmp.Nodes.ContainsKey(tmpNodeName))
                {
                    tmp = tmp.AddNode(tmpNodeName);
                }
                else
                {
                    tmp = tmp.Nodes[tmpNodeName];
                }
                index++;
            }
            return(tmp);
        }
Example #2
0
 public FuncTreeNode(string name)
 {
     this._name = name;
     this._parent = null;
     this._funcs = new Dictionary<string, CustomShellType.FuncCode>();
     this._nodes = new Dictionary<string, FuncTreeNode>();
 }
Example #3
0
 public FuncTreeNode(string name)
 {
     this._name   = name;
     this._parent = null;
     this._funcs  = new Dictionary <string, CustomShellType.FuncCode>();
     this._nodes  = new Dictionary <string, FuncTreeNode>();
 }
Example #4
0
        public CustomShellType(Basic basicSetting,
                               MainCode mainCodeSetting)
        {
            _shellTypeName   = basicSetting.ShellTypeName;
            _basicSetting    = basicSetting;
            _mainCodeSetting = mainCodeSetting;

            //初始化方法树
            _funcTreeRoot = new FuncTreeNode(_shellTypeName);
        }
Example #5
0
 public FuncTreeNode AddNode(string nodeName)
 {
     if (!this.Nodes.ContainsKey(nodeName))
     {
         FuncTreeNode newNode = new FuncTreeNode(nodeName);
         newNode._parent = this;
         this.Nodes.Add(newNode.Name, newNode);
         return newNode;
     }
     return this.Nodes[nodeName];
 }
Example #6
0
        public FuncTreeNode AddFuncTreeNode(string nodeXpath)
        {
            FuncTreeNode tmp = _funcTreeRoot.FindNodes(nodeXpath);

            //如果节点不存在
            if (tmp == null)
            {
                return(_funcTreeRoot.AddNodes(nodeXpath));
            }
            return(tmp);
        }
Example #7
0
 public FuncTreeNode AddNode(string nodeName)
 {
     if (!this.Nodes.ContainsKey(nodeName))
     {
         FuncTreeNode newNode = new FuncTreeNode(nodeName);
         newNode._parent = this;
         this.Nodes.Add(newNode.Name, newNode);
         return(newNode);
     }
     return(this.Nodes[nodeName]);
 }
Example #8
0
        public FuncCode GetFuncCode(string nodeXpath, string funcCodeName)
        {
            FuncTreeNode tmp = _funcTreeRoot.FindNodes(nodeXpath);

            //如果节点存在
            if (tmp != null)
            {
                //如果funcCode已经注册
                if (tmp.Funcs.ContainsKey(funcCodeName))
                {
                    return(tmp.Funcs[funcCodeName]);
                }
            }
            //其他情况均为未注册
            throw new Exception(string.Format("FuncCode:[{0}/{1}/{2}] hasn't been registered", _shellTypeName, nodeXpath, funcCodeName));
        }
Example #9
0
        public void AddFuncCode(string nodeXpath, FuncCode funcCode)
        {
            FuncTreeNode tmp = _funcTreeRoot.FindNodes(nodeXpath);

            //如果节点不存在
            if (tmp == null)
            {
                throw new Exception(string.Format("FuncTreeNode:[{0}/{1}] has't been defined", _shellTypeName, nodeXpath));
            }
            //如果funcCode已经注册
            if (tmp.Funcs.ContainsKey(funcCode.Name))
            {
                throw new Exception(string.Format("FuncCode:[{0}/{1}/{2}] has been registered", _shellTypeName, nodeXpath, funcCode.Name));
            }
            else
            {
                tmp.Funcs.Add(funcCode.Name, funcCode);
            }
        }
Example #10
0
        public FuncTreeNode FindNodes(string xpath)
        {
            string[] paths = xpath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            if (paths.Length == 0)
            {
                return(this);
            }
            int          index = 0;
            FuncTreeNode tmp   = this;

            while (index < paths.Length)
            {
                tmp = tmp.FindNode(paths[index]);
                if (tmp != null)
                {
                    index++;
                }
                else
                {
                    break;
                }
            }
            return(tmp);
        }
Example #11
0
        public CustomShellType(Basic basicSetting,
                               MainCode mainCodeSetting)
        {
            _shellTypeName = basicSetting.ShellTypeName;
            _basicSetting = basicSetting;
            _mainCodeSetting = mainCodeSetting;

            //初始化方法树
            _funcTreeRoot = new FuncTreeNode(_shellTypeName);
        }