Пример #1
0
        /// <summary>
        /// Select elements from within a context.
        /// </summary>
        ///
        /// <param name="selector">
        /// A string containing a selector expression.
        /// </param>
        /// <param name="context">
        /// The point in the document at which the selector should begin matching; similar to the context
        /// argument of the CQ.Create(selector, context) method.
        /// </param>
        ///
        /// <returns>
        /// A new CQ object.
        /// </returns>
        ///
        /// <url>
        /// http://api.jquery.com/jQuery/#jQuery1
        /// </url>

        public CQ Select(string selector, IDomObject context)
        {
            var selectors = new Selector(selector);
            var selection = selectors.ToContextSelector().Select(Document, context);

            CQ csq = NewInstance(selection, this);
            csq.Selector = selectors;
            return csq;
        }
Пример #2
0
        private CQ FindImpl(Selector selector)
        {
            CQ csq = NewCqInDomain();
            var selection = selector.ToContextSelector().Select(Document, this);

            csq.AddSelection(selection);
            csq.Selector = selector;
            return csq;
        }
Пример #3
0
        /// <summary>
        /// Configures a new instance for a sequence of elements and an existing context.
        /// </summary>
        ///
        /// <param name="selector">
        /// A valid CSS selector.
        /// </param>
        /// <param name="context">
        /// The context.
        /// </param>

        private void ConfigureNewInstance(string selector, CQ context)
        {
            CsQueryParent = context;

            if (!String.IsNullOrEmpty(selector))
            {
                Selector = new Selector(selector);

                SetSelection(Selector.ToContextSelector().Select(Document, context),
                    Selector.IsHtml ?
                        SelectionSetOrder.OrderAdded :
                        SelectionSetOrder.Ascending);
            }

        }