/// <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); } }