예제 #1
0
 public HtmlTagNester <TSelf> ThenAppendChild(string name, int indentSize = 2)
 {
     if (IsTag)
     {
         var el = new HtmlTagNester <TSelf>(name, true, indentSize)
         {
             Parent = this
         };
         Children.Add(el);
         return(el);
     }
     if (Parent == null)
     {
         throw new Exception("You can't append to non tag with no parent");
     }
     return(Parent.AppendChild(name, true, indentSize));
 }
예제 #2
0
 public HtmlTagNester <TSelf> ThenAppendChild(string name, out HtmlTagNester <TSelf> element, bool isTag = true, int indentSize = 2)
 {
     if (IsTag)
     {
         element = new HtmlTagNester <TSelf>(name, isTag, indentSize)
         {
             Parent = this
         };
         Children.Add(element);
         return(element);
     }
     if (Parent == null)
     {
         throw new Exception("You can't append to non tag with no parent");
     }
     Parent.AppendChild(name, out element, isTag, indentSize);
     return(element);
 }
예제 #3
0
            // Stack over flow problem
            public HtmlTagNester <TSelf> AppendChild(string name, out HtmlTagNester <TSelf> element, bool isTag = true, int indentSize = 2)
            {
                var el = new HtmlTagNester <TSelf>(name, isTag, indentSize);

                if (IsTag)
                {
                    el.Parent = this;
                    element   = el;
                    Children.Add(el);
                    return(this);
                }
                // if no parent and this is not a tag we must throw an error
                if (Parent == null)
                {
                    throw new Exception("You can't append to non tag with no parent");
                }
                Parent.AppendChild(name, out element, isTag, indentSize);
                return(this);
            }
예제 #4
0
 public HtmlTagNester <TSelf> AppendText(string text, out HtmlTagNester <TSelf> element, int indentSize = 2)
 {
     return(AppendChild(text, out element, false, indentSize));
 }