コード例 #1
0
        /// <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;
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        /// <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;
        }
コード例 #5
0
ファイル: HtmlElement.cs プロジェクト: zhanghan19/Headless
        /// <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();
        }
コード例 #6
0
        /// <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));
        }
コード例 #7
0
ファイル: AnyHtmlElement.cs プロジェクト: zhanghan19/Headless
 /// <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)
 {
 }
コード例 #8
0
 /// <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)
 {
 }
コード例 #9
0
 /// <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)
 {
 }
コード例 #10
0
ファイル: HtmlTableRow.cs プロジェクト: zhanghan19/Headless
 /// <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)
 {
 }
コード例 #11
0
 /// <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)
 {
 }
コード例 #12
0
 /// <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)
 {
 }
コード例 #13
0
ファイル: HtmlCheckBox.cs プロジェクト: roryprimrose/Headless
 /// <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)
 {
 }
コード例 #14
0
ファイル: HtmlCheckBox.cs プロジェクト: zhanghan19/Headless
 /// <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)
 {
 }
コード例 #15
0
 /// <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)
 {
 }
コード例 #16
0
ファイル: HtmlInput.cs プロジェクト: roryprimrose/Headless
 /// <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)
 {
 }
コード例 #17
0
 /// <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();
 }
コード例 #18
0
ファイル: HtmlFile.cs プロジェクト: roryprimrose/Headless
 /// <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)
 {
 }
コード例 #19
0
ファイル: HtmlFile.cs プロジェクト: zhanghan19/Headless
 /// <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)
 {
 }
コード例 #20
0
ファイル: HtmlButton.cs プロジェクト: zhanghan19/Headless
 /// <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)
 {
 }
コード例 #21
0
ファイル: HtmlListItem.cs プロジェクト: roryprimrose/Headless
 /// <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)
 {
 }
コード例 #22
0
 /// <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();
 }
コード例 #23
0
 /// <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)
 {
 }
コード例 #24
0
 /// <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)
 {
 }
コード例 #25
0
 /// <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)
 {
 }
コード例 #26
0
 /// <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)
 {
 }
コード例 #27
0
 /// <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)
 {
 }
コード例 #28
0
 /// <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)
 {
 }