Exemplo n.º 1
0
 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));
     }
 }
Exemplo n.º 2
0
 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);
     }
 }