Esempio n. 1
0
        /// <summary>
        /// Adds classes to the HTML attribute "class". Multiple calls add additional values.
        /// </summary>
        /// <param name="classes">The list of classes to add.</param>
        /// <returns>The same instance of <see cref="Hex.AttributeBuilders.HtmlAttributeBuilder"/>.</returns>
        public HtmlAttributeBuilder AddClass( params string[] classes )
        {
            if( classes == null )
            {
                return this;
            }

            AttributeValueCollection attributeValues = null;
            if( !this.Attributes.TryGetValue<AttributeValueCollection>( HtmlAttributes.Class, out attributeValues ) )
            {
                attributeValues = new AttributeValueCollection();
                this.Attributes[ HtmlAttributes.Class ] = attributeValues;
            }

            attributeValues.AddRange( classes );
            return this;
        }
Esempio n. 2
0
        /// <summary>
        /// Provides a way of adding a generic attribute that contains multiple values separated by a space. Multiple calls add additional values.
        /// </summary>
        /// <param name="name">The name of the attribute.</param>
        /// <param name="values">The list of values.</param>
        /// <returns>The same instance of <see cref="Hex.AttributeBuilders.HtmlAttributeBuilder"/>.</returns>
        public HtmlAttributeBuilder AddMultiValueAttribute( string name, params object[] values )
        {
            if( !string.IsNullOrWhiteSpace( name ) )
            {
                AttributeValueCollection attributeValues = null;
                if( !this.Attributes.TryGetValue<AttributeValueCollection>( name, out attributeValues ) )
                {
                    attributeValues = new AttributeValueCollection();
                    this.Attributes[ name ] = attributeValues;
                }

                attributeValues.AddRange( values );
            }

            return this;
        }