Implement AngleSharp.XPath breaking changes

Bump of B warranted, more in the release notes
This commit is contained in:
JustArchi
2022-08-06 18:51:32 +02:00
parent 5c6ca3fee2
commit f3229fa45f
10 changed files with 64 additions and 48 deletions

View File

@@ -189,24 +189,45 @@ public static class Utilities {
}
[PublicAPI]
public static IEnumerable<IElement> SelectNodes(this IDocument document, string xpath) {
public static IList<INode> SelectNodes(this IDocument document, string xpath) {
ArgumentNullException.ThrowIfNull(document);
return document.Body.SelectNodes(xpath).OfType<IElement>();
return document.Body.SelectNodes(xpath);
}
[PublicAPI]
public static IElement? SelectSingleElementNode(this IElement element, string xpath) {
public static IEnumerable<T> SelectNodes<T>(this IDocument document, string xpath) where T : class, INode {
ArgumentNullException.ThrowIfNull(document);
return document.SelectNodes(xpath).OfType<T>();
}
[PublicAPI]
public static IEnumerable<T> SelectNodes<T>(this IElement element, string xpath) where T : class, INode {
ArgumentNullException.ThrowIfNull(element);
return (IElement?) element.SelectSingleNode(xpath);
return element.SelectNodes(xpath).OfType<T>();
}
[PublicAPI]
public static IElement? SelectSingleNode(this IDocument document, string xpath) {
public static INode? SelectSingleNode(this IDocument document, string xpath) {
ArgumentNullException.ThrowIfNull(document);
return (IElement?) document.Body.SelectSingleNode(xpath);
return document.Body.SelectSingleNode(xpath);
}
[PublicAPI]
public static T? SelectSingleNode<T>(this IDocument document, string xpath) where T : class, INode {
ArgumentNullException.ThrowIfNull(document);
return document.Body.SelectSingleNode(xpath) as T;
}
[PublicAPI]
public static T? SelectSingleNode<T>(this IElement element, string xpath) where T : class, INode {
ArgumentNullException.ThrowIfNull(element);
return element.SelectSingleNode(xpath) as T;
}
[PublicAPI]