예제 #1
0
        /// <summary>
        /// 创建层叠选择器
        /// </summary>
        /// <param name="elements">作为范畴限定的元素集</param>
        /// <param name="expression">选择器表达式</param>
        /// <returns>层叠选择器</returns>
        public static ISelector Create(IEnumerable <IHtmlElement> elements, string expression)
        {
            if (elements == null)
            {
                throw new ArgumentNullException("elements");
            }

            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            var selector = CssParser.ParseSelector(expression);

            if (elements.IsNullOrEmpty())
            {
                return(selector);
            }

            var relativeSelector = new CssAncetorRelativeSelector(new CssElementsRestrictionSelector(elements));

            return(Create(relativeSelector, selector));
        }
예제 #2
0
    /// <summary>
    /// 创建层叠选择器
    /// </summary>
    /// <param name="elements">作为范畴限定的元素集</param>
    /// <param name="expression">选择器表达式</param>
    /// <returns>层叠选择器</returns>
    public static ISelector Create( IEnumerable<IHtmlElement> elements, string expression )
    {

      if ( elements == null )
        throw new ArgumentNullException( "elements" );

      if ( expression == null )
        throw new ArgumentNullException( "expression" );

      var selector = CssParser.ParseSelector( expression );

      if ( elements.IsNullOrEmpty() )
        return selector;

      var relativeSelector = new CssAncetorRelativeSelector( new CssElementsRestrictionSelector( elements ) );

      return Create( relativeSelector, selector );
    }