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)); }
public HtmlTagNester <TSelf> AppendChild(string name, bool isTag = true, int indentSize = 2) { var el = new HtmlTagNester <TSelf>(name, isTag, indentSize); if (IsTag) { el.Parent = this; 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"); } el = Parent.AppendChild(name, isTag, indentSize); return(this); }
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); }
public HtmlTagNester <TSelf> AppendText(string text, out HtmlTagNester <TSelf> element, int indentSize = 2) { return(AppendChild(text, out element, false, indentSize)); }