/// <summary> /// Initializes a new instance of the <see cref="DefaultHtmlElementFinder{T}"/> class. /// </summary> /// <param name="element"> /// The element. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="element"/> parameter is <c>null</c>. /// </exception> public DefaultHtmlElementFinder(HtmlElement element) { if (element == null) { throw new ArgumentNullException("element"); } _page = element.Page; _node = element.Node; }
/// <inheritdoc /> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page" /> parameter is <c>null</c>. /// </exception> public void Initialize(IHtmlPage page) { if (page == null) { throw new ArgumentNullException("page"); } Initialize(page.Browser, page.StatusCode, page.StatusDescription, page.Result); _content = page.Document; }
/// <inheritdoc /> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page" /> parameter is <c>null</c>. /// </exception> public void Initialize(IHtmlPage page) { if (page == null) { throw new ArgumentNullException("page"); } var location = page.Result.Outcomes.Last().Location; _wrapperPage = new HtmlPageWrapper(location); _wrapperPage.Initialize(page); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultHtmlElementFinder{T}"/> class. /// </summary> /// <param name="page"> /// The page. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> public DefaultHtmlElementFinder(IHtmlPage page) { if (page == null) { throw new ArgumentNullException("page"); } _page = page; var navigator = page.Document.GetNavigator(); navigator.MoveToRoot(); _node = navigator; }
/// <summary> /// Initializes a new instance of the <see cref="HtmlElement"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> protected HtmlElement(IHtmlPage page, IXPathNavigable node) { if (page == null) { throw new ArgumentNullException("page"); } if (node == null) { throw new ArgumentNullException("node"); } _page = page; _node = node; ValidateNode(); }
/// <inheritdoc /> public T Create <T>(IHtmlPage page, IXPathNavigable node) where T : HtmlElement { // Find the most appropriate type that supports this node var sourceType = typeof(T); // Find a constructor on the type that takes in HtmlPage and IXPathNavigable var typeToCreate = sourceType.FindBestMatchingType(node); if (sourceType.IsAssignableFrom(typeToCreate) == false) { var message = string.Format( CultureInfo.CurrentCulture, "The instance could not be created because {0} does not inherit from {1}.", typeToCreate.FullName, sourceType.FullName); throw new InvalidOperationException(message); } return((T)Activator.CreateInstance(typeToCreate, page, node)); }
/// <summary> /// Initializes a new instance of the <see cref="AnyHtmlElement"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public AnyHtmlElement(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="SecondConflictType"/> class. /// </summary> /// <param name="page"> /// The page. /// </param> /// <param name="node"> /// The node. /// </param> public SecondConflictType(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="HtmlFormElement"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> protected HtmlFormElement(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="HtmlTableRow"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public HtmlTableRow(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="FirstConflictType"/> class. /// </summary> /// <param name="page"> /// The page. /// </param> /// <param name="node"> /// The node. /// </param> public FirstConflictType(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="HtmlCheckBox"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public HtmlCheckBox(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="HtmlInput"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public HtmlInput(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="HtmlRadioButton"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public HtmlRadioButton(IHtmlPage page, IXPathNavigable node) : base(page, node) { _relatedNodes = FindRelatedNodes(); }
/// <summary> /// Initializes a new instance of the <see cref="HtmlFile"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public HtmlFile(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="HtmlButton"/> class. /// </summary> /// <param name="page"> /// The page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public HtmlButton(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="HtmlListItem"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public HtmlListItem(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="HtmlTableCell"/> class. /// </summary> /// <param name="page"> /// The owning page. /// </param> /// <param name="node"> /// The node. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="node"/> parameter is <c>null</c>. /// </exception> public HtmlTableCell(IHtmlPage page, IXPathNavigable node) : base(page, node) { }
/// <summary> /// Initializes a new instance of the <see cref="AncestorHtmlElementFinder{T}"/> class. /// </summary> /// <param name="page"> /// The page to search. /// </param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="page"/> parameter is <c>null</c>. /// </exception> public AncestorHtmlElementFinder(IHtmlPage page) : base(page) { }