/// <summary> /// Initializes a new instance of the <see cref="HtmlAttribute"/> class. /// </summary> /// <remarks> /// Creates a new HTML attribute with the given id and value. /// </remarks> /// <param name="id">The attribute identifier.</param> /// <param name="value">The attribute value.</param> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="id"/> is not a valid value. /// </exception> public HtmlAttribute (HtmlAttributeId id, string value) { if (id == HtmlAttributeId.Unknown) throw new ArgumentOutOfRangeException ("id"); Name = id.ToAttributeName (); Value = value; Id = id; }
/// <summary> /// Initializes a new instance of the <see cref="HtmlAttribute"/> class. /// </summary> /// <remarks> /// Creates a new HTML attribute with the given id and value. /// </remarks> /// <param name="id">The attribute identifier.</param> /// <param name="value">The attribute value.</param> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="id"/> is not a valid value. /// </exception> public HtmlAttribute(HtmlAttributeId id, string value) { if (id == HtmlAttributeId.Unknown) { throw new ArgumentOutOfRangeException("id"); } Name = id.ToAttributeName(); Value = value; Id = id; }
/// <summary> /// Write the attribute to the output stream. /// </summary> /// <remarks> /// Writes the attribute to the output stream. /// </remarks> /// <param name="id">The attribute identifier.</param> /// <param name="buffer">A buffer containing the attribute value.</param> /// <param name="index">The starting index of the attribute value.</param> /// <param name="count">The number of characters in the attribute value.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="id"/> is not a valid HTML attribute identifier. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="buffer"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <para><paramref name="index"/> is less than zero or greater than the length of /// <paramref name="buffer"/>.</para> /// <para>-or-</para> /// <para><paramref name="index"/> and <paramref name="count"/> do not specify /// a valid range in the <paramref name="buffer"/>.</para> /// </exception> /// <exception cref="System.InvalidOperationException"> /// The <see cref="HtmlWriter"/> is not in a state that allows writing attributes. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteAttribute(HtmlAttributeId id, char[] buffer, int index, int count) { if (id == HtmlAttributeId.Unknown) { throw new ArgumentException("Invalid attribute.", nameof(id)); } ValidateArguments(buffer, index, count); CheckDisposed(); EncodeAttribute(id.ToAttributeName(), buffer, index, count); }
/// <summary> /// Write the attribute name to the output stream. /// </summary> /// <remarks> /// Writes the attribute name to the output stream. /// </remarks> /// <param name="id">The attribute identifier.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="id"/> is not a valid HTML attribute identifier. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The <see cref="HtmlWriter"/> is not in a state that allows writing attributes. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteAttributeName(HtmlAttributeId id) { if (id == HtmlAttributeId.Unknown) { throw new ArgumentException("Invalid attribute.", nameof(id)); } if (WriterState == HtmlWriterState.Default) { throw new InvalidOperationException("Cannot write attributes in the Default state."); } CheckDisposed(); EncodeAttributeName(id.ToAttributeName()); }
/// <summary> /// Write the attribute to the output stream. /// </summary> /// <remarks> /// Writes the attribute to the output stream. /// </remarks> /// <example> /// <code language="c#" source="Examples\MimeVisitorExamples.cs" region="HtmlPreviewVisitor" /> /// </example> /// <param name="id">The attribute identifier.</param> /// <param name="value">The attribute value.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="id"/> is not a valid HTML attribute identifier. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="value"/> is <c>null</c>. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The <see cref="HtmlWriter"/> is not in a state that allows writing attributes. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteAttribute(HtmlAttributeId id, string value) { if (id == HtmlAttributeId.Unknown) { throw new ArgumentException("Invalid attribute.", nameof(id)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } CheckDisposed(); EncodeAttribute(id.ToAttributeName(), value); }
/// <summary> /// Write the attribute to the output stream. /// </summary> /// <remarks> /// Writes the attribute to the output stream. /// </remarks> /// <param name="id">The attribute identifier.</param> /// <param name="value">The attribute value.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="id"/> is not a valid HTML attribute identifier. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="value"/> is <c>null</c>. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The <see cref="HtmlWriter"/> is not in a state that allows writing attributes. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteAttribute (HtmlAttributeId id, string value) { if (id == HtmlAttributeId.Unknown) throw new ArgumentException ("Invalid attribute.", "id"); if (value == null) throw new ArgumentNullException ("value"); CheckDisposed (); EncodeAttribute (id.ToAttributeName (), value); }
/// <summary> /// Write the attribute to the output stream. /// </summary> /// <remarks> /// Writes the attribute to the output stream. /// </remarks> /// <param name="id">The attribute identifier.</param> /// <param name="buffer">A buffer containing the attribute value.</param> /// <param name="index">The starting index of the attribute value.</param> /// <param name="count">The number of characters in the attribute value.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="id"/> is not a valid HTML attribute identifier. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="buffer"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <para><paramref name="index"/> is less than zero or greater than the length of /// <paramref name="buffer"/>.</para> /// <para>-or-</para> /// <para><paramref name="index"/> and <paramref name="count"/> do not specify /// a valid range in the <paramref name="buffer"/>.</para> /// </exception> /// <exception cref="System.InvalidOperationException"> /// The <see cref="HtmlWriter"/> is not in a state that allows writing attributes. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteAttribute (HtmlAttributeId id, char[] buffer, int index, int count) { if (id == HtmlAttributeId.Unknown) throw new ArgumentException ("Invalid attribute.", "id"); ValidateArguments (buffer, index, count); CheckDisposed (); EncodeAttribute (id.ToAttributeName (), buffer, index, count); }
/// <summary> /// Write the attribute name to the output stream. /// </summary> /// <remarks> /// Writes the attribute name to the output stream. /// </remarks> /// <param name="id">The attribute identifier.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="id"/> is not a valid HTML attribute identifier. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The <see cref="HtmlWriter"/> is not in a state that allows writing attributes. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteAttributeName (HtmlAttributeId id) { if (id == HtmlAttributeId.Unknown) throw new ArgumentException ("Invalid attribute.", "id"); if (WriterState == HtmlWriterState.Default) throw new InvalidOperationException ("Cannot write attributes in the Default state."); CheckDisposed (); EncodeAttributeName (id.ToAttributeName ()); }