コード例 #1
0
 internal CssSimpleSelectorSequence(ICssSelectorSequence sequence, CssSimpleSelector otherSelector)
     : base(CalculateSpecificity(sequence, otherSelector))
 {
     ArgChecker.AssertIsTrue <ArgumentException>(!(otherSelector is CssTypeSelector), "Selector sequence cannot contain more than one type selector.");
     _typeSelector   = sequence.TypeSelector;
     _otherSelectors = sequence.OtherSelectors.Add(otherSelector);
 }
コード例 #2
0
 internal CssSimpleSelectorSequence(ICssSelectorSequence sequence, CssPseudoElement pseudoElement)
     : base(CalculateSpecificity(sequence, pseudoElement))
 {
     ArgChecker.AssertIsTrue <ArgumentException>(sequence.Subject.PseudoElement == null, "Selector sequence cannot contain more than one pseudo-element.");
     _typeSelector   = sequence.TypeSelector;
     _otherSelectors = sequence.OtherSelectors;
     _pseudoElement  = pseudoElement;
 }
コード例 #3
0
 internal CssSelectorCombination(CssCombinator combinator, ICssSelectorChain leftOperand, ICssSelectorSequence rightOperand)
     : base(CalculateSpecificity(leftOperand, rightOperand))
 {
     ArgChecker.AssertIsTrue <ArgumentException>(leftOperand.Subject.PseudoElement == null,
                                                 "Pseudo-elements are only allowed in the right operand of a combinator");
     _combinator   = combinator;
     _leftOperand  = leftOperand;
     _rightOperand = rightOperand;
 }
コード例 #4
0
        /// <summary>
        /// Creates a new <see cref="CssSimpleSelectorSequence"/> consisting of a given sequence with additional selectors appended.
        /// </summary>
        /// <param name="sequence">A <see cref="CssTypeSelector"/> or <see cref="CssSimpleSelectorSequence"/> instance.</param>
        /// <param name="otherSelectors">Zero or more simple, non-type selectors to append to the original sequence.</param>
        /// <returns>a new <see cref="CssSimpleSelectorSequence"/> consisting of the original <paramref name="sequence"/> followed
        /// by <paramref name="otherSelectors"/>.</returns>
        public static ICssSelectorSequence AddRange(this ICssSelectorSequence sequence, IEnumerable <CssSimpleSelector> otherSelectors)
        {
            var result = sequence;

            foreach (var otherSelector in otherSelectors)
            {
                result = result.Add(otherSelector);
            }
            return(result);
        }
コード例 #5
0
 /// <summary>
 /// Creates a selector consisting of two selector sequences and a <see cref="CssCombinator"/>.
 /// </summary>
 /// <param name="leftSelector">The left operand of the combination operator.</param>
 /// <param name="combinator">The combination operator.</param>
 /// <param name="rightSelector">The right operand of the combination operator.</param>
 /// <returns>The newly created combined selector.</returns>
 public static ICssSelectorChain Combine(this ICssSelectorChain leftSelector, CssCombinator combinator, ICssSelectorSequence rightSelector)
 {
     return(new CssSelectorCombination(combinator, leftSelector, rightSelector));
 }
コード例 #6
0
 /// <summary>
 /// Creates a new <see cref="CssSimpleSelectorSequence"/> consisting of a given sequence with an additional pseudo-element appended.
 /// </summary>
 /// <param name="sequence">A <see cref="CssTypeSelector"/> or <see cref="CssSimpleSelectorSequence"/> instance.</param>
 /// <param name="pseudoElement">The pseudo-element to append.</param>
 /// <returns>a new <see cref="CssSimpleSelectorSequence"/> consisting of the original <paramref name="sequence"/> followed
 /// by the <paramref name="pseudoElement"/>.</returns>
 public static ICssSelectorSequence Add(this ICssSelectorSequence sequence, CssPseudoElement pseudoElement)
 {
     return(new CssSimpleSelectorSequence(sequence, pseudoElement));
 }
コード例 #7
0
 /// <summary>
 /// Creates a new <see cref="CssSimpleSelectorSequence"/> consisting of a given sequence with an additional selector appended.
 /// </summary>
 /// <param name="sequence">A <see cref="CssTypeSelector"/> or <see cref="CssSimpleSelectorSequence"/> instance.</param>
 /// <param name="otherSelector">A simple, non-type selector to append to the original sequence.</param>
 /// <returns>a new <see cref="CssSimpleSelectorSequence"/> consisting of the original <paramref name="sequence"/> followed
 /// by <paramref name="otherSelector"/>.</returns>
 public static ICssSelectorSequence Add(this ICssSelectorSequence sequence, CssSimpleSelector otherSelector)
 {
     return(new CssSimpleSelectorSequence(sequence, otherSelector));
 }
コード例 #8
0
 public CombinationTerm(CssCombinator combinator, ICssSelectorSequence rightOperand)
 {
     this.Combinator   = combinator;
     this.RightOperand = rightOperand;
 }
コード例 #9
0
 private static CssSpecificity CalculateSpecificity(ICssSelectorSequence sequence, CssPseudoElement pseudoElement)
 {
     ArgChecker.AssertArgNotNull(sequence, nameof(sequence));
     ArgChecker.AssertArgNotNull(pseudoElement, nameof(pseudoElement));
     return(sequence.Specificity + new CssSpecificity(1, 0, 0));
 }
コード例 #10
0
 private static CssSpecificity CalculateSpecificity(ICssSelectorSequence sequence, CssSimpleSelector otherSelector)
 {
     ArgChecker.AssertArgNotNull(sequence, nameof(sequence));
     ArgChecker.AssertArgNotNull(otherSelector, nameof(otherSelector));
     return(sequence.Specificity + otherSelector.Specificity);
 }
コード例 #11
0
 private static CssSpecificity CalculateSpecificity(ICssSelectorChain leftOperand, ICssSelectorSequence rightOperand)
 {
     ArgChecker.AssertArgNotNull(leftOperand, nameof(leftOperand));
     ArgChecker.AssertArgNotNull(rightOperand, nameof(rightOperand));
     return(leftOperand.Specificity + rightOperand.Specificity);
 }