/// <summary> /// Creates and initializes an SblGroup. /// </summary> /// <param name="name">The name of the node.</param> /// <param name="subItems">An enumerable object that represents a list of subitems.</param> public SblGroup(string name, IEnumerable subItems) { Name = name; Items = new List <SblNode>(); foreach (object o in subItems) { SblNode node = o as SblNode; if (node != null) { Items.Add(node); } } }
private SblNode GetSblNodeCaseSensitive(string name) { SblNode result = null; for (int i = 0; i < Items.Count; i++) { if (Items[i].Name.Equals(name)) { if (result != null) // Ambiguous match { return(null); } result = Items[i]; } } return(result); }
private SblNode GetSblNodeCaseInsensitive(string name) { SblNode result = null; for (int i = 0; i < Items.Count; i++) { if (Items[i].Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)) { if (result != null) // Ambiguous match { return(null); } result = Items[i]; } } return(result); }
/// <summary> /// Gets a node by name. There must be a node with a unique name that matches the name /// parameter. If there are zero or more than one matching results no node will be returned. /// </summary> /// <param name="name">The name of the node to return.</param> /// <returns>T node if there is one and only one node that matches the specified name, or null otherwise.</returns> public override SblNode this[string name] { get { SblNode result = null; for (int i = 0; i < Items.Count; i++) { if (Items[i].Name.Equals(name)) { if (result != null) // Ambiguous match { return(null); } result = Items[i]; } } return(result); } }