Пример #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);
        }
Пример #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>();
 }
Пример #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>();
 }
Пример #4
0
        public CustomShellType(Basic basicSetting,
                               MainCode mainCodeSetting)
        {
            _shellTypeName   = basicSetting.ShellTypeName;
            _basicSetting    = basicSetting;
            _mainCodeSetting = mainCodeSetting;

            //初始化方法树
            _funcTreeRoot = new FuncTreeNode(_shellTypeName);
        }
Пример #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];
 }
Пример #6
0
        public FuncTreeNode AddFuncTreeNode(string nodeXpath)
        {
            FuncTreeNode tmp = _funcTreeRoot.FindNodes(nodeXpath);

            //如果节点不存在
            if (tmp == null)
            {
                return(_funcTreeRoot.AddNodes(nodeXpath));
            }
            return(tmp);
        }
Пример #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]);
 }
Пример #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));
        }
Пример #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);
            }
        }
Пример #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);
        }
Пример #11
0
        public CustomShellType(Basic basicSetting,
                               MainCode mainCodeSetting)
        {
            _shellTypeName = basicSetting.ShellTypeName;
            _basicSetting = basicSetting;
            _mainCodeSetting = mainCodeSetting;

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