C# Class CsQuery.Engine.SelectorEngine

Exibir arquivo Open project: prepare/HTML-Renderer Class Usage Examples

Public Methods

Method Description
GetDescendantElements ( IDomObject element ) : IEnumerable
GetDescendantElements ( IEnumerable list ) : IEnumerable

Return all descendants of each element in the list

Select ( IEnumerable context ) : IList

Select implementation. The public method automatically remaps a selector with the knowledge that the context is external (and not part of a chain)

SelectorEngine ( IDomDocument document, CsQuery.Engine.Selector selector ) : System

Protected Methods

Method Description
GetAdjacentElements ( IEnumerable list ) : IEnumerable
GetAdjacentOrSiblings ( TraversalType traversalType, IEnumerable list ) : IEnumerable

Map a list to its siblings or adjacent elements if needed. Ignore other traversal types.

GetAllChildOrDescendants ( TraversalType traversalType, IEnumerable list ) : IEnumerable

Map a list to its children or descendants, if needed.

GetAllElements ( IEnumerable list ) : IEnumerable
GetChildElements ( IEnumerable list ) : IEnumerable

Return all children of each element in the list

GetMatches ( IEnumerable source, CsQuery.Engine.SelectorClause selector ) : IEnumerable

Return all elements matching a selector, within a list of elements. This function will traverse children, but it is expected that the source list at the current depth (e.g. from an Adjacent or Sibling selector) is already processed.

GetPseudoClassMatches ( IDomElement elm, CsQuery.Engine.SelectorClause selector ) : IEnumerable

Return all child elements matching a DOM-position type selector

GetResultPositionMatches ( IEnumerable list, CsQuery.Engine.SelectorClause selector ) : IEnumerable

Return all position-type matches. These are selectors that are keyed to the position within the selection set itself.

GetSelectionSource ( CsQuery.Engine.SelectorClause clause, IEnumerable context, IEnumerable lastResult ) : IEnumerable

Get the sequence that is the source for the current clause, based on the selector, prior results, and context.

Notes from refactoring this on 10/14/2012: At issue is selectors like ":not(.sel1 .sel2, :first) where the subselector has filters that apply to just the context, versus selectors like ":has(.sel1 .sel2, :first) where the subselector needs to apply to the results of a selection against the DOM case1: $('.sel','.context-sel') means that ".sel" is actually applied against .context-sel. it's like .find. totally different from a subselector -- but the subselector still needs a context to apply filters, even though the selectors theselves are run against the whole doc. so we need to set up selectors before running against the context so each subselector is IDd as either "context" or "root" in addition to its traversal type to eliminate ambiguity of intent. a subselector for :not should have "root+descendant" for the first part and "context+filter" for the 2nd. For regular context type filters, it should be "context+descendant" (same as find). FOr complex context/find filters chained with a comma, the stuff after the comma should also be in context though jquery seems inconsistent with this. This code here should then use the new info to select the correct sleection source. Think we should be rid of traversaltype.subselect. Think traversaltype.all should really mean "include the context items" instead of "Descendant" as it does now.

GetSiblings ( IEnumerable list ) : IEnumerable
GetTraversalTargetElements ( TraversalType traversalType, IEnumerable list ) : IEnumerable
Matches ( CsQuery.Engine.SelectorClause selector, IDomElement obj, int depth ) : bool

Return true if an object matches a specific selector. If the selector has a desecendant or child traversal type, it must also match the specificed depth.

MatchesPseudoClass ( IDomElement element, CsQuery.Engine.SelectorClause selector ) : bool

Return true if an element matches a specific filter.

Private Methods

Method Description
EmptyEnumerable ( ) : IEnumerable
GetFeatures ( IDomIndex index ) : DomIndexFeatures

Method Details

GetAdjacentElements() protected method

protected GetAdjacentElements ( IEnumerable list ) : IEnumerable
list IEnumerable
return IEnumerable

GetAdjacentOrSiblings() protected method

Map a list to its siblings or adjacent elements if needed. Ignore other traversal types.
protected GetAdjacentOrSiblings ( TraversalType traversalType, IEnumerable list ) : IEnumerable
traversalType TraversalType /// The traversal type ///
list IEnumerable /// The source list ///
return IEnumerable

GetAllChildOrDescendants() protected method

Map a list to its children or descendants, if needed.
protected GetAllChildOrDescendants ( TraversalType traversalType, IEnumerable list ) : IEnumerable
traversalType TraversalType
list IEnumerable
return IEnumerable

GetAllElements() protected method

protected GetAllElements ( IEnumerable list ) : IEnumerable
list IEnumerable
return IEnumerable

GetChildElements() protected method

Return all children of each element in the list
protected GetChildElements ( IEnumerable list ) : IEnumerable
list IEnumerable
return IEnumerable

GetDescendantElements() public static method

public static GetDescendantElements ( IDomObject element ) : IEnumerable
element IDomObject
return IEnumerable

GetDescendantElements() public static method

Return all descendants of each element in the list
public static GetDescendantElements ( IEnumerable list ) : IEnumerable
list IEnumerable
return IEnumerable

GetMatches() protected method

Return all elements matching a selector, within a list of elements. This function will traverse children, but it is expected that the source list at the current depth (e.g. from an Adjacent or Sibling selector) is already processed.
protected GetMatches ( IEnumerable source, CsQuery.Engine.SelectorClause selector ) : IEnumerable
source IEnumerable /// The sequence of elements to filter. ///
selector CsQuery.Engine.SelectorClause /// The selector. ///
return IEnumerable

GetPseudoClassMatches() protected method

Return all child elements matching a DOM-position type selector
protected GetPseudoClassMatches ( IDomElement elm, CsQuery.Engine.SelectorClause selector ) : IEnumerable
elm IDomElement
selector CsQuery.Engine.SelectorClause
return IEnumerable

GetResultPositionMatches() protected method

Return all position-type matches. These are selectors that are keyed to the position within the selection set itself.
protected GetResultPositionMatches ( IEnumerable list, CsQuery.Engine.SelectorClause selector ) : IEnumerable
list IEnumerable /// The list of elements to filter ///
selector CsQuery.Engine.SelectorClause /// The selector ///
return IEnumerable

GetSelectionSource() protected method

Get the sequence that is the source for the current clause, based on the selector, prior results, and context.
Notes from refactoring this on 10/14/2012: At issue is selectors like ":not(.sel1 .sel2, :first) where the subselector has filters that apply to just the context, versus selectors like ":has(.sel1 .sel2, :first) where the subselector needs to apply to the results of a selection against the DOM case1: $('.sel','.context-sel') means that ".sel" is actually applied against .context-sel. it's like .find. totally different from a subselector -- but the subselector still needs a context to apply filters, even though the selectors theselves are run against the whole doc. so we need to set up selectors before running against the context so each subselector is IDd as either "context" or "root" in addition to its traversal type to eliminate ambiguity of intent. a subselector for :not should have "root+descendant" for the first part and "context+filter" for the 2nd. For regular context type filters, it should be "context+descendant" (same as find). FOr complex context/find filters chained with a comma, the stuff after the comma should also be in context though jquery seems inconsistent with this. This code here should then use the new info to select the correct sleection source. Think we should be rid of traversaltype.subselect. Think traversaltype.all should really mean "include the context items" instead of "Descendant" as it does now.
protected GetSelectionSource ( CsQuery.Engine.SelectorClause clause, IEnumerable context, IEnumerable lastResult ) : IEnumerable
clause CsQuery.Engine.SelectorClause /// The current selector clause. ///
context IEnumerable /// The context passed initially to this Select operation. ///
lastResult IEnumerable /// The result of the prior clause. Can be null. ///
return IEnumerable

GetSiblings() protected method

protected GetSiblings ( IEnumerable list ) : IEnumerable
list IEnumerable
return IEnumerable

GetTraversalTargetElements() protected method

protected GetTraversalTargetElements ( TraversalType traversalType, IEnumerable list ) : IEnumerable
traversalType TraversalType
list IEnumerable
return IEnumerable

Matches() protected method

Return true if an object matches a specific selector. If the selector has a desecendant or child traversal type, it must also match the specificed depth.
protected Matches ( CsQuery.Engine.SelectorClause selector, IDomElement obj, int depth ) : bool
selector CsQuery.Engine.SelectorClause The jQuery/CSS selector
obj IDomElement The target object
depth int The depth at which the target must appear for descendant or child selectors
return bool

MatchesPseudoClass() protected method

Return true if an element matches a specific filter.
protected MatchesPseudoClass ( IDomElement element, CsQuery.Engine.SelectorClause selector ) : bool
element IDomElement /// The element to test ///
selector CsQuery.Engine.SelectorClause /// A selector clause ///
return bool

Select() public method

Select implementation. The public method automatically remaps a selector with the knowledge that the context is external (and not part of a chain)
/// Thrown when one or more required arguments are null. ///
public Select ( IEnumerable context ) : IList
context IEnumerable /// The context in which the selector applies. If null, the selector is run against the entire /// Document. If not, the selector is run against this sequence of elements. ///
return IList

SelectorEngine() public method

public SelectorEngine ( IDomDocument document, CsQuery.Engine.Selector selector ) : System
document IDomDocument
selector CsQuery.Engine.Selector
return System