Beispiel #1
0
        public List <CssElement> Parse()
        {
            var elements = new List <CssElement>();

            while (!Eof())
            {
                var elementName = ParseElementName();

                if (elementName == null)
                {
                    break;
                }

                var element = new CssElement(elementName);

                var name  = ParseAttributeName();
                var value = ParseAttributeValue();

                while (name != null && value != null)
                {
                    element.Add(name, value);

                    EatWhiteSpace();

                    if (GetCurrentChar() == '}')
                    {
                        m_idx++;
                        break;
                    }

                    name  = ParseAttributeName();
                    value = ParseAttributeValue();
                }

                elements.Add(element);
            }

            return(elements);
        }
Beispiel #2
0
 /// <summary>
 /// 添加一个元素。
 /// </summary>
 /// <param name="element"></param>
 public void Add(CssElement element)
 {
     Elements.Add(element);
 }