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); }
public FuncTreeNode(string name) { this._name = name; this._parent = null; this._funcs = new Dictionary<string, CustomShellType.FuncCode>(); this._nodes = new Dictionary<string, FuncTreeNode>(); }
public FuncTreeNode(string name) { this._name = name; this._parent = null; this._funcs = new Dictionary <string, CustomShellType.FuncCode>(); this._nodes = new Dictionary <string, FuncTreeNode>(); }
public CustomShellType(Basic basicSetting, MainCode mainCodeSetting) { _shellTypeName = basicSetting.ShellTypeName; _basicSetting = basicSetting; _mainCodeSetting = mainCodeSetting; //初始化方法树 _funcTreeRoot = new FuncTreeNode(_shellTypeName); }
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]; }
public FuncTreeNode AddFuncTreeNode(string nodeXpath) { FuncTreeNode tmp = _funcTreeRoot.FindNodes(nodeXpath); //如果节点不存在 if (tmp == null) { return(_funcTreeRoot.AddNodes(nodeXpath)); } return(tmp); }
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]); }
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)); }
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); } }
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); }