IsValidTokenName() static private method

static private IsValidTokenName ( string name ) : bool
name string
return bool
示例#1
0
        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));
            }
        }
示例#2
0
        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");
            }
        }
示例#3
0
        /// <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;
        }