Exemple #1
0
        void CloseLastTag()
        {
            var node = current;

            current = stack.Pop();
            current.Children.Add(node);
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        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);
                }
            }
        }
Exemple #4
0
        public void Visit(HtmlNode.Tag tag)
        {
            if (predicate(tag))
            {
                Result.Add(tag);
            }

            tag.Children.ForEach(x => x.AcceptVisitor(this));
        }
Exemple #5
0
 public HtmlBuilder()
 {
     current = new HtmlNode.Tag();
     stack   = new Stack <HtmlNode.Tag>();
 }
Exemple #6
0
 public void OpenTag(string name, Dictionary <string, string> attributes)
 {
     stack.Push(current);
     current = new HtmlNode.Tag(name, attributes, new List <HtmlNode>());
 }
Exemple #7
0
 void CloseLastTag()
 {
     var node = current;
     current = stack.Pop();
     current.Children.Add(node);
 }
Exemple #8
0
 public void OpenTag(string name, Dictionary<string, string> attributes)
 {
     stack.Push(current);
     current = new HtmlNode.Tag(name, attributes, new List<HtmlNode>());
 }
Exemple #9
0
 public HtmlBuilder()
 {
     current = new HtmlNode.Tag();
     stack = new Stack<HtmlNode.Tag>();
 }