Ejemplo n.º 1
0
        /// <summary>
        /// Process a attributes
        /// </summary>
        /// <returns>List of attributes</returns>
        private List <XmlAttribute> ProcessAttributes()
        {
            var    attributes = new List <XmlAttribute>();
            string content    = _innerContext.SourceCode;

            Match match = _attributeRegex.Match(content, _innerContext.Position, _innerContext.RemainderLength);

            while (match.Success)
            {
                GroupCollection groups = match.Groups;

                string attributeName  = groups["attributeName"].Value;
                string attributeValue = groups["attributeValue"].Value;
                if (!string.IsNullOrWhiteSpace(attributeValue))
                {
                    attributeValue = XmlAttributeValueHelpers.Decode(attributeValue);
                }
                var attribute = new XmlAttribute(attributeName, attributeValue);

                attributes.Add(attribute);

                _innerContext.IncreasePosition(match.Length);
                match = _attributeRegex.Match(content, _innerContext.Position, _innerContext.RemainderLength);
            }

            return(attributes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes a attributes to buffer
        /// </summary>
        /// <param name="attributes">List of attributes</param>
        private void WriteAttributes(List <XmlAttribute> attributes)
        {
            int attributeCount = attributes.Count;

            for (int attributeIndex = 0; attributeIndex < attributeCount; attributeIndex++)
            {
                XmlAttribute attribute             = attributes[attributeIndex];
                string       encodedAttributeValue = XmlAttributeValueHelpers.Encode(attribute.Value);

                XmlMinificationOutputWriter output = _output;
                output.Write(" ");
                output.Write(attribute.Name);
                output.Write("=\"");
                output.Write(encodedAttributeValue);
                output.Write("\"");
            }
        }