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));
            }
Exemplo n.º 3
0
 internal static IEnumerable <DomNode> FilterDescendants(DomObjectQuery q, Func <DomNode, bool> predicate)
 {
     return(q.OfType <DomNode>().SelectMany(e => e.DescendantNodesAndSelf.Where(predicate)));
 }
Exemplo n.º 4
0
 internal static IEnumerable <DomElement> FilterChildren(DomObjectQuery q, Func <DomElement, bool> predicate)
 {
     return(q.OfType <DomContainer>().SelectMany(e => e.Children.Where(predicate)));
 }
Exemplo n.º 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);
 }