// Token: 0x0600001C RID: 28 RVA: 0x000027E4 File Offset: 0x000017E4 public void addCategory(string path, string template, string filename) { if (template.Length == 0) { throw new XmlException(string.Concat(new string[] { "The category with a pattern: ", path, " found in file: ", filename, " has an empty template tag. ABORTING" })); } if (path.Trim().Length == 0) { this.template = template; this.filename = filename; return; } string[] array = path.Trim().Split(" ".ToCharArray()); string text = MakeCaseInsensitive.TransformInput(array[0]); string path2 = path.Substring(text.Length, path.Length - text.Length).Trim(); if (this.children.ContainsKey(text)) { Node node = this.children[text]; node.addCategory(path2, template, filename); return; } Node node2 = new Node(); node2.word = text; node2.addCategory(path2, template, filename); this.children.Add(node2.word, node2); }
/// <summary> /// Adds a category to the node /// </summary> /// <param name="path">the path for the category</param> /// <param name="template">the template to find at the end of the path</param> /// <param name="filename">the file that was the source of this category</param> public void addCategory(string path, string template, string filename) { if (template.Length == 0) { throw new XmlException("The category with a pattern: " + path + " found in file: " + filename + " has an empty template tag. ABORTING"); } // check we're not at the leaf node if (path.Trim().Length == 0) { this.template = template; this.filename = filename; return; } // otherwise, this sentence requires further child nodemappers in order to // be fully mapped within the GraphMaster structure. // split the input into its component words string[] words = path.Trim().Split(" ".ToCharArray()); // get the first word (to form the key for the child nodemapper) string firstWord = Normalize.MakeCaseInsensitive.TransformInput(words[0]); // concatenate the rest of the sentence into a suffix (to act as the // path argument in the child nodemapper) string newPath = path.Substring(firstWord.Length, path.Length - firstWord.Length).Trim(); // o.k. check we don't already have a child with the key from this sentence Node childNode = (Node)this.children[firstWord]; // if we do then pass the handling of this sentence down the branch to the // child nodemapper otherwise the child nodemapper doesn't yet exist, so create a new one if (object.Equals(null, childNode)) { childNode = new Node(); childNode.word = firstWord; childNode.addCategory(newPath, template, filename); this.children.Add(childNode.word, childNode); } else { childNode.addCategory(newPath, template, filename); } }
/// <summary> /// Adds a category to the node /// </summary> /// <param name="path">the path for the category</param> /// <param name="template">the template to find at the end of the path</param> /// <param name="filename">the file that was the source of this category</param> public void addCategory(string path, string template, string filename) { if (template.Length == 0) { throw new XmlException("The category with a pattern: " + path + " found in file: " + filename + " has an empty template tag. ABORTING"); } // check we're not at the leaf node if (path.Trim().Length == 0) { this.template = template; this.filename = filename; return; } // otherwise, this sentence requires further child nodemappers in order to // be fully mapped within the GraphMaster structure. // split the input into its component words string[] words = path.Trim().Split(" ".ToCharArray()); // get the first word (to form the key for the child nodemapper) string firstWord = Normalize.MakeCaseInsensitive.TransformInput(words[0]); // concatenate the rest of the sentence into a suffix (to act as the // path argument in the child nodemapper) string newPath = path.Substring(firstWord.Length, path.Length - firstWord.Length).Trim(); // o.k. check we don't already have a child with the key from this sentence // if we do then pass the handling of this sentence down the branch to the // child nodemapper otherwise the child nodemapper doesn't yet exist, so create a new one if (this.children.ContainsKey(firstWord)) { Node childNode = this.children[firstWord]; childNode.addCategory(newPath, template, filename); } else { Node childNode = new Node(); childNode.word = firstWord; childNode.addCategory(newPath, template, filename); this.children.Add(childNode.word, childNode); } }
public void addCategory(string path, string template, string filename) { if (template.Length == 0) { throw new XmlException("路径: " + path + ",文件 : " + filename + " 没有包含任何标签"); } if (path.Trim().Length == 0) { this.template = template; this.filename = filename; return; } List <string> words = new List <string>(); string w = ""; foreach (char c in path.ToCharArray()) { if (Regex.IsMatch(c.ToString(), @"[\u4e00-\u9fa5]+")) { if (w != "") { words.Add(w.ToString()); } w = ""; words.Add(c.ToString()); } else if (c.ToString() == "*") { w = ""; words.Add(c.ToString()); } else { if (c != ' ') { w += c.ToString(); } else if (w != "") { words.Add(w.ToString()); w = ""; } } } if (w != "") { words.Add(w.ToString()); } string firstWord = Normalize.MakeCaseInsensitive.TransformInput(words[0]); string newPath = path.Substring(firstWord.Length, path.Length - firstWord.Length).Trim(); if (this.children.ContainsKey(firstWord)) { Node childNode = this.children[firstWord]; childNode.addCategory(newPath, template, filename); } else { Node childNode = new Node(); childNode.word = firstWord; childNode.addCategory(newPath, template, filename); this.children.Add(childNode.word, childNode); } }