Example #1
0
        /// <summary>
        /// Gets the page URL via the page attributes.
        /// </summary>
        /// <param name="browser">The browser.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>
        /// The URL stricture from the page.
        /// </returns>
        /// <exception cref="PageNavigationException">No PageAttribute or PageNavigationAttribute exists on type: {0}</exception>
        /// <exception cref="PageNavigationException">Thrown if the page is not able to navigate to.</exception>
        private static UriStructure GetPageUriInternal(IBrowser browser, Type pageType)
        {
            PageNavigationAttribute pageNavigationAttribute;

            if (pageType.TryGetAttribute(out pageNavigationAttribute))
            {
                return(new UriStructure(pageNavigationAttribute.Url,
                                        pageNavigationAttribute.IsAbsoluteUrl,
                                        pageNavigationAttribute.UrlTemplate));
            }

            var browserUri = browser.GetUriForPageType(pageType);

            if (!string.IsNullOrWhiteSpace(browserUri))
            {
                return(new UriStructure(browserUri, false));
            }

            throw new PageNavigationException("No PageNavigationAttribute exists on type: {0}", pageType.Name);
        }
Example #2
0
        /// <summary>
        /// Gets the page URL via the page attributes.
        /// </summary>
        /// <param name="browser">The browser.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>
        /// The URL stricture from the page.
        /// </returns>
        /// <exception cref="PageNavigationException">No PageAttribute or PageNavigationAttribute exists on type: {0}</exception>
        /// <exception cref="PageNavigationException">Thrown if the page is not able to navigate to.</exception>
        private static UriStructure GetPageUriInternal(IBrowser browser, Type pageType)
        {
            PageNavigationAttribute pageNavigationAttribute;
            if (pageType.TryGetAttribute(out pageNavigationAttribute))
            {
                return new UriStructure(pageNavigationAttribute.Url, 
                                        pageNavigationAttribute.IsAbsoluteUrl,
                                        pageNavigationAttribute.UrlTemplate);
            }

            var browserUri = browser.GetUriForPageType(pageType);
            if (!string.IsNullOrWhiteSpace(browserUri))
            {
                return new UriStructure(browserUri, false);
            }

            throw new PageNavigationException("No PageNavigationAttribute exists on type: {0}", pageType.Name);
        }
Example #3
0
 public string GetUriForPageType(Type pageType)
 {
     return(browser.GetUriForPageType(pageType));
 }