static void ValidateTagName(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (name.Length == 0) { throw new ArgumentException("The tag name cannot be empty.", nameof(name)); } if (!HtmlUtils.IsValidTokenName(name)) { throw new ArgumentException("Invalid tag name.", nameof(name)); } }
static void ValidateAttributeName(string name) { if (name == null) { throw new ArgumentNullException("name"); } if (name.Length == 0) { throw new ArgumentException("The attribute name cannot be empty.", "name"); } if (!HtmlUtils.IsValidTokenName(name)) { throw new ArgumentException("Invalid attribute name.", "name"); } }
/// <summary> /// Initializes a new instance of the <see cref="HtmlAttribute"/> class. /// </summary> /// <remarks> /// Creates a new HTML attribute with the given name and value. /// </remarks> /// <param name="name">The attribute name.</param> /// <param name="value">The attribute value.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="name"/> is <c>null</c>. /// </exception> public HtmlAttribute(string name, string value) { if (name == null) { throw new ArgumentNullException("name"); } if (name.Length == 0) { throw new ArgumentException("The attribute name cannot be empty.", "name"); } if (!HtmlUtils.IsValidTokenName(name)) { throw new ArgumentException("Invalid attribute name.", "name"); } Id = name.ToHtmlAttributeId(); Value = value; Name = name; }