public static IHtmlNode AsNode(this AP.HtmlNode node) { switch (node.NodeType) { case AP.HtmlNodeType.Element: return(new HtmlElementAdapter(node)); case AP.HtmlNodeType.Text: return(node.CastTo <AP.HtmlTextNode>().AsTextNode()); case AP.HtmlNodeType.Comment: return(node.CastTo <AP.HtmlCommentNode>().AsComment()); default: throw new NotSupportedException(); } }