/// <summary> /// Write the HTML tag to a <see cref="System.IO.TextWriter"/>. /// </summary> /// <remarks> /// Writes the HTML tag to a <see cref="System.IO.TextWriter"/>. /// </remarks> /// <param name="output">The output.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="output"/> is <c>null</c>. /// </exception> public override void WriteTo(TextWriter output) { if (output == null) { throw new ArgumentNullException("output"); } output.Write('<'); if (IsEndTag) { output.Write('/'); } output.Write(Name); for (int i = 0; i < Attributes.Count; i++) { output.Write(' '); output.Write(Attributes[i].Name); if (Attributes[i].Value != null) { output.Write('='); HtmlUtils.HtmlEncodeAttribute(output, Attributes[i].Value); } } if (IsEmptyElement) { output.Write('/'); } output.Write('>'); }
void EncodeAttributeValue(string value) { if (WriterState != HtmlWriterState.Attribute) { throw new InvalidOperationException("Attribute values can only be written in the Attribute state."); } html.Write('='); HtmlUtils.HtmlEncodeAttribute(html, value); WriterState = HtmlWriterState.Tag; }
void EncodeAttributeValue(char[] value, int startIndex, int count) { if (WriterState != HtmlWriterState.Attribute) { throw new InvalidOperationException("Attribute values can only be written in the Attribute state."); } html.Write('='); HtmlUtils.HtmlEncodeAttribute(html, value, startIndex, count); WriterState = HtmlWriterState.Tag; }