public DomObjectQuery ReplaceWith(params DomNode[] others)
 {
     if (others == null)
     {
         throw new ArgumentNullException(nameof(others));
     }
     return(QueryMany(
                n => DomObjectQuery._ReplaceWith(n, others),
                n => DomObjectQuery._ReplaceWith(n, DomNode.CloneAll(others))
                ));
 }
            internal override DomObjectQuery Apply(DomObjectQuery root, DomObjectQuery q)
            {
                IEnumerable <DomElement> result;

                if (Index >= 0)
                {
                    result = FilterChildren(q, e => e.Name == Name && e.ElementPosition == Index);
                }
                else
                {
                    result = FilterChildren(q, e => e.Name == Name);
                }
                return(new DomObjectQuery(result));
            }
示例#3
0
 internal static IEnumerable <DomNode> FilterDescendants(DomObjectQuery q, Func <DomNode, bool> predicate)
 {
     return(q.OfType <DomNode>().SelectMany(e => e.DescendantNodesAndSelf.Where(predicate)));
 }
示例#4
0
 internal static IEnumerable <DomElement> FilterChildren(DomObjectQuery q, Func <DomElement, bool> predicate)
 {
     return(q.OfType <DomContainer>().SelectMany(e => e.Children.Where(predicate)));
 }
示例#5
0
 internal abstract DomObjectQuery Apply(DomObjectQuery root, DomObjectQuery q);
 internal override DomObjectQuery Apply(DomObjectQuery root, DomObjectQuery q)
 {
     return(new DomObjectQuery(FilterDescendants(q, e => e.Attribute(Name) == Value)));
 }
 internal override DomObjectQuery Apply(DomObjectQuery root, DomObjectQuery q)
 {
     return(new DomObjectQuery(
                q.OfType <DomContainer>().Select(ele => ele.Attributes[Name]).NonNull()
                ));
 }
 internal override DomObjectQuery Apply(DomObjectQuery root, DomObjectQuery q)
 {
     return(root);
 }