コード例 #1
0
ファイル: SelectorFactory.cs プロジェクト: tocsoft/ExCSS
        private void PrasePseudoClassFunctionEnd(Block token)
        {
            _selectorOperation = SelectorOperation.Data;

            if (token.GrammarSegment != GrammarSegment.ParenClose)
            {
                return;
            }

            switch (_attributeName)
            {
            case PseudoSelectorPrefix.PseudoFunctionNthchild:
            case PseudoSelectorPrefix.PseudoFunctionNthlastchild:
            case PseudoSelectorPrefix.PseudoFunctionNthOfType:
            case PseudoSelectorPrefix.PseudoFunctionNthLastOfType:
                Insert(GetNthChildSelector());
                break;

            case PseudoSelectorPrefix.PseudoFunctionNot:
                Insert(new PseudoNotFunctionSelector(_nestedSelectorFactory.GetSelector()));
                break;

            case PseudoSelectorPrefix.PseudoFunctionDir:
                Insert(new PseudoFunctionSelector(PseudoSelectorPrefix.PseudoFunctionDir, _attributeValue));
                break;

            case PseudoSelectorPrefix.PseudoFunctionLang:
                Insert(new PseudoFunctionSelector(PseudoSelectorPrefix.PseudoFunctionLang, _attributeValue));
                break;

            case PseudoSelectorPrefix.PseudoFunctionContains:
                Insert(new PseudoFunctionSelector(PseudoSelectorPrefix.PseudoFunctionContains, _attributeValue));
                break;
            }
        }
コード例 #2
0
        private void PrasePseudoClassFunctionEnd(Block token)
        {
            _selectorOperation = SelectorOperation.Data;

            if (token.GrammarSegment != GrammarSegment.ParenClose)
            {
                return;
            }

            switch (_attributeName)
            {
            case PseudoSelectorPrefix.PseudoFunctionNthchild:
                Insert(GetChildSelector <NthFirstChildSelector>());
                break;

            case PseudoSelectorPrefix.PseudoFunctionNthlastchild:
                Insert(GetChildSelector <NthLastChildSelector>());
                break;

            case PseudoSelectorPrefix.PseudoFunctionNthOfType:
                Insert(GetChildSelector <NthOfTypeSelector>());
                break;

            case PseudoSelectorPrefix.PseudoFunctionNthLastOfType:
                Insert(GetChildSelector <NthLastOfTypeSelector>());
                break;

            case PseudoSelectorPrefix.PseudoFunctionNot:
            {
                var selector = _nestedSelectorFactory.GetSelector();
                var code     = string.Format("{0}({1})", PseudoSelectorPrefix.PseudoFunctionNot, selector);
                Insert(SimpleSelector.PseudoClass(code));
                break;
            }

            case PseudoSelectorPrefix.PseudoFunctionDir:
            {
                var code = string.Format("{0}({1})", PseudoSelectorPrefix.PseudoFunctionDir, _attributeValue);
                Insert(SimpleSelector.PseudoClass(code));
                break;
            }

            case PseudoSelectorPrefix.PseudoFunctionLang:
            {
                var code = string.Format("{0}({1})", PseudoSelectorPrefix.PseudoFunctionLang, _attributeValue);
                Insert(SimpleSelector.PseudoClass(code));
                break;
            }

            case PseudoSelectorPrefix.PseudoFunctionContains:
            {
                var code = string.Format("{0}({1})", PseudoSelectorPrefix.PseudoFunctionContains, _attributeValue);
                Insert(SimpleSelector.PseudoClass(code));
                break;
            }
            }
        }
コード例 #3
0
ファイル: Parser.cs プロジェクト: bcanzanella/ExCSS
        internal static BaseSelector ParseSelector(string selector)
        {
            var tokenizer = new Lexer(new StylesheetReader(selector));
            var tokens    = tokenizer.Tokens;
            var selctor   = new SelectorFactory();

            foreach (var token in tokens)
            {
                selctor.Apply(token);
            }

            var result = selctor.GetSelector();

            return(result);
        }