示例#1
0
        private void InsertCommaDelimited()
        {
            if (_currentSelector == null)
            {
                return;
            }

            if (_aggregateSelectorList == null)
            {
                _aggregateSelectorList = new AggregateSelectorList(",");
            }

            if (_complexSelector != null)
            {
                _complexSelector.ConcludeSelector(_currentSelector);
                _aggregateSelectorList.AppendSelector(_complexSelector);
                _complexSelector = null;
            }
            else
            {
                _aggregateSelectorList.AppendSelector(_currentSelector);
            }

            _currentSelector = null;
        }
示例#2
0
        internal BaseSelector GetSelector()
        {
            if (_complexSelector != null)
            {
                _complexSelector.ConcludeSelector(_currentSelector);
                _currentSelector = _complexSelector;
            }

            if (_aggregateSelectorList == null || _aggregateSelectorList.Length == 0)
            {
                return(_currentSelector ?? SimpleSelector.All);
            }

            if (_currentSelector == null && _aggregateSelectorList.Length == 1)
            {
                return(_aggregateSelectorList[0]);
            }

            if (_currentSelector == null)
            {
                return(_aggregateSelectorList);
            }

            _aggregateSelectorList.AppendSelector(_currentSelector);
            _currentSelector = null;

            return(_aggregateSelectorList);
        }
示例#3
0
        internal SelectorFactory ResetFactory()
        {
            _attributeName         = null;
            _attributeValue        = null;
            _attributeOperator     = string.Empty;
            _selectorOperation     = SelectorOperation.Data;
            _combinator            = Combinator.Descendent;
            _hasCombinator         = false;
            _currentSelector       = null;
            _aggregateSelectorList = null;
            _complexSelector       = null;

            return(this);
        }
示例#4
0
        private void Insert(BaseSelector selector)
        {
            if (_currentSelector != null)
            {
                if (!_hasCombinator)
                {
                    var compound = _currentSelector as AggregateSelectorList;

                    if (compound == null)
                    {
                        compound = new AggregateSelectorList("");
                        compound.AppendSelector(_currentSelector);
                    }

                    compound.AppendSelector(selector);
                    _currentSelector = compound;
                }
                else
                {
                    if (_complexSelector == null)
                    {
                        _complexSelector = new ComplexSelector();
                    }

                    _complexSelector.AppendSelector(_currentSelector, _combinator);
                    _combinator      = Combinator.Descendent;
                    _hasCombinator   = false;
                    _currentSelector = selector;
                }
            }
            else
            {
                if (_currentSelector == null && _complexSelector == null && _combinator == Combinator.Namespace)
                {
                    _complexSelector = new ComplexSelector();
                    _complexSelector.AppendSelector(SimpleSelector.Type(""), _combinator);
                    _currentSelector = selector;
                }
                else
                {
                    _combinator      = Combinator.Descendent;
                    _hasCombinator   = false;
                    _currentSelector = selector;
                }
            }
        }
示例#5
0
 internal void ConcludeSelector(BaseSelector selector)
 {
     _selectors.Add(new CombinatorSelector {
         Selector = selector
     });
 }
示例#6
0
        BaseSelector ObfuscateSelectors(BaseSelector selector)
        {
            Type ruleType = selector.GetType();

            if (ruleType == typeof(SimpleSelector))
            {
                string obf = ObfuscateSelectorPart(selector.ToString());
                if (obf == null)
                    return selector;
                else
                    return new SimpleSelector(obf);
            }

            if (ruleType == typeof(ComplexSelector))
            {
                var obf = new ComplexSelector();
                var cs = (ComplexSelector)selector;
                foreach (var sel in cs)
                    obf.AppendSelector(ObfuscateSelectors(sel.Selector), sel.Delimiter);
                return obf;
            }

            if (ruleType == typeof(AggregateSelectorList))
            {
                var cs = (AggregateSelectorList)selector;
                var obf = new AggregateSelectorList(cs.Delimiter);
                foreach (BaseSelector sel in cs)
                    obf.AppendSelector(ObfuscateSelectors(sel));
                return obf;
            }

            if (ruleType == typeof(MultipleSelectorList))
            {
                var obf = new MultipleSelectorList();
                var cs = (MultipleSelectorList)selector;
                foreach (BaseSelector sel in cs)
                    obf.AppendSelector(ObfuscateSelectors(sel));
                return obf;
            }

            return selector;
        }
示例#7
0
 public ComplexSelector AppendSelector(BaseSelector selector, Combinator combinator)
 {
     _selectors.Add(new CombinatorSelector(selector, combinator));
     return(this);
 }
示例#8
0
 public void ConcludeSelector(BaseSelector selector)
 {
     _selectors.Add(new CombinatorSelector(selector, Combinator.Child));
 }
示例#9
0
 public CombinatorSelector(BaseSelector selector, Combinator delimiter)
 {
     Selector  = selector;
     Delimiter = delimiter;
 }
示例#10
0
 public CombinatorSelector(BaseSelector selector, Combinator delimiter)
 {
     Selector = selector;
     Delimiter = delimiter;
 }
示例#11
0
 public PseudoNotFunctionSelector(BaseSelector selector) : base(PseudoSelectorPrefix.PseudoFunctionNot)
 {
     _selector = selector;
 }