/// <summary> /// Recursive search that returns a list of all nodes with the specified name /// </summary> /// <param name="name">The node name.</param> /// <param name="searchAllChildren">if set to <c>true</c> search deeply.</param> /// <param name="collection">The collection under inspection.</param> /// <param name="foundNodes">The previously found nodes.</param> /// <returns>A collection of the previously found nodes with any newly found nodes from the collection under inspection.</returns> private SettingsNodeList FindInternal(string name, bool searchAllChildren, SettingsNodeList collection, SettingsNodeList foundNodes) { if ((collection == null) || (foundNodes == null)) { return(null); } for (int i = 0; i < collection.Count; i++) { if (collection[i] != null && collection[i].Name == name) { foundNodes.Add(collection[i]); } } if (searchAllChildren) { for (int i = 0; i < collection.Count; i++) { if (collection[i] != null && collection[i].Nodes != null && collection[i].Nodes.Count > 0) { foundNodes = this.FindInternal(name, searchAllChildren, collection[i].Nodes, foundNodes); } } } return(foundNodes); }
/// <summary> /// Returns a list of all nodes in the collection that have names which contain the specified string. /// </summary> /// <param name="namePartial">The partial node name.</param> /// <returns>A SettingsNodeList of found nodes.</returns> public SettingsNodeList SelectNodesContaining(string namePartial) { SettingsNodeList nodes = new SettingsNodeList(_parent); foreach (SettingsNode node in _nodeIndices) { if (node.Name.Contains(namePartial)) { nodes.Add(node); } } return(nodes); }
/// <summary> /// Returns a list of all nodes in the collection that have names starting with the specified string. /// </summary> /// <param name="nameBeginning">The name beginning.</param> /// <returns>A SettingsNodeList of found nodes.</returns> public SettingsNodeList SelectNodesStartingWith(string nameBeginning) { SettingsNodeList nodes = new SettingsNodeList(_parent); foreach (SettingsNode node in _nodeIndices) { if (node.Name.StartsWith(nameBeginning)) { nodes.Add(node); } } return(nodes); }