public bool TryGetChild(PathToken token, out PatternNode?node) { if (token.IsSet) { var child = this.SetChildren.FirstOrDefault(c => c.SetName == token.Text); if (child == null) { node = null; return(false); } node = child.Node; return(true); } else { return(this.Children.TryGetValue(token.Text, out node)); } }
public PatternNode GetOrAddChild(PathToken token) { if (token.IsSet) { var child = this.SetChildren.FirstOrDefault(c => c.SetName == token.Text); if (child == null) { var node = new PatternNode(this.children.Comparer); this.setChildren.Add(new SetChild(token.Text, node)); return(node); } return(child.Node); } else { if (this.Children.TryGetValue(token.Text, out var node)) { return(node); } node = new PatternNode(this.children.Comparer); this.children.Add(token.Text, node); return(node); } }