internal void WriteAttributes(TextWriter outText, bool closing)
{
if (_ownerdocument.OptionOutputAsXml)
{
if (_attributes == null)
{
return;
}
// we use _hashitems to make sure attributes are written only once
foreach(HtmlAttribute att in _attributes._hashitems.Values)
{
WriteAttribute(outText, att);
}
return;
}
if (!closing)
{
if (_attributes != null)
{
foreach(HtmlAttribute att in _attributes)
{
WriteAttribute(outText, att);
}
}
if (_ownerdocument.OptionAddDebuggingAttributes)
{
WriteAttribute(outText, _ownerdocument.CreateAttribute("_closed", Closed.ToString()));
WriteAttribute(outText, _ownerdocument.CreateAttribute("_children", ChildNodes.Count.ToString()));
int i = 0;
foreach(HtmlNode n in ChildNodes)
{
WriteAttribute(outText, _ownerdocument.CreateAttribute("_child_" + i,
n.Name));
i++;
}
}
}
else
{
if (_endnode == null)
{
return;
}
if (_endnode._attributes == null)
{
return;
}
if (_endnode == this)
{
return;
}
foreach(HtmlAttribute att in _endnode._attributes)
{
WriteAttribute(outText, att);
}
if (_ownerdocument.OptionAddDebuggingAttributes)
{
WriteAttribute(outText, _ownerdocument.CreateAttribute("_closed", Closed.ToString()));
WriteAttribute(outText, _ownerdocument.CreateAttribute("_children", ChildNodes.Count.ToString()));
}
}
}