void CloseLastTag() { var node = current; current = stack.Pop(); current.Children.Add(node); }
public void CloseTag(string name) { if (current.Name == "") { // unreal situation stack.Count!=0 && current.Name=="" if (stack.Count != 0) { throw new Exception(); } var node = new HtmlNode.Tag(name, current.Attributes, current.Children); current.Attributes = new Dictionary <string, string>(); current.Children = new List <HtmlNode>(); current.Children.Add(node); } else { if (current.Name == name) { CloseLastTag(); } else { CloseLastTag(); CloseTag(name); } } }
public void CloseTag(string name) { if (current.Name == "") { // unreal situation stack.Count!=0 && current.Name=="" if (stack.Count != 0) throw new Exception(); var node = new HtmlNode.Tag(name, current.Attributes, current.Children); current.Attributes = new Dictionary<string, string>(); current.Children = new List<HtmlNode>(); current.Children.Add(node); } else { if (current.Name == name) { CloseLastTag(); } else { CloseLastTag(); CloseTag(name); } } }
public void Visit(HtmlNode.Tag tag) { if (predicate(tag)) { Result.Add(tag); } tag.Children.ForEach(x => x.AcceptVisitor(this)); }
public HtmlBuilder() { current = new HtmlNode.Tag(); stack = new Stack <HtmlNode.Tag>(); }
public void OpenTag(string name, Dictionary <string, string> attributes) { stack.Push(current); current = new HtmlNode.Tag(name, attributes, new List <HtmlNode>()); }
public void OpenTag(string name, Dictionary<string, string> attributes) { stack.Push(current); current = new HtmlNode.Tag(name, attributes, new List<HtmlNode>()); }
public HtmlBuilder() { current = new HtmlNode.Tag(); stack = new Stack<HtmlNode.Tag>(); }