Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 5
0
        /// <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();
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 7
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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 10
0
 /// <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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 13
0
 /// <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)
 {
 }
Ejemplo n.º 14
0
 /// <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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 16
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)
 {
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 18
0
 /// <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)
 {
 }
Ejemplo n.º 19
0
 /// <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)
 {
 }
Ejemplo n.º 20
0
 /// <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)
 {
 }
Ejemplo n.º 21
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)
 {
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }
 /// <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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }