示例#1
0
文件: Selector.cs 项目: Epitomy/CMS
        public static Selector Parse(string str)
        {
            Selector result = new Selector();

            SelectorReader reader = new SelectorReader(str);
            SelectorCombinator combinator = null;
            SimpleSelectorChain simpleSelectors = new SimpleSelectorChain();

            while (!reader.EndOfStream)
            {
                switch (reader.Status)
                {
                    case SelectorReader.ReadStatus.Combinator:
                        result.Add(combinator, simpleSelectors);
                        combinator = reader.ReadCombinator();
                        simpleSelectors = new SimpleSelectorChain();
                        break;
                    case SelectorReader.ReadStatus.SimpleSelector:
                        SimpleSelector simpleSelector = reader.ReadSimpleSelector();
                        if (simpleSelector.Type == SelectorType.PseudoElement)
                        {
                            result.PseudoElementSelector = simpleSelector;
                        }
                        simpleSelectors.Add(simpleSelector);
                        break;
                }
            }
            result.Add(combinator, simpleSelectors);

            return result;
        }
示例#2
0
        public static Selector Parse(string str)
        {
            Selector result = new Selector();

            SelectorReader      reader          = new SelectorReader(str);
            SelectorCombinator  combinator      = null;
            SimpleSelectorChain simpleSelectors = new SimpleSelectorChain();

            while (!reader.EndOfStream)
            {
                switch (reader.Status)
                {
                case SelectorReader.ReadStatus.Combinator:
                    result.Add(combinator, simpleSelectors);
                    combinator      = reader.ReadCombinator();
                    simpleSelectors = new SimpleSelectorChain();
                    break;

                case SelectorReader.ReadStatus.SimpleSelector:
                    SimpleSelector simpleSelector = reader.ReadSimpleSelector();
                    if (simpleSelector.Type == SelectorType.PseudoElement)
                    {
                        result.PseudoElementSelector = simpleSelector;
                    }
                    simpleSelectors.Add(simpleSelector);
                    break;
                }
            }
            result.Add(combinator, simpleSelectors);

            return(result);
        }