예제 #1
0
        /// <summary>
        /// Gets an IUrlRewriteItem from the IUrlRewriteItem collection by name
        /// </summary>
        /// <param name="name">The name</param>
        /// <returns></returns>
        public IUrlRewriteItem GetUrlRewriteItem(string name)
        {
            IUrlRewriteItem item       = null;
            IEnumerator     enumerator = this.UrlRewriteElementCollection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (((IUrlRewriteItem)enumerator.Current).Name.Equals(name))
                {
                    item = ((IUrlRewriteItem)enumerator.Current);
                    break;
                }
            }

            return(item);
        }
예제 #2
0
        /// <summary>
        /// Gets the breadcrumbs.
        /// </summary>
        /// <param name="output">The output.</param>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        protected virtual StringBuilder GetBreadcrumbs(StringBuilder output, IUrlRewriteItem item)
        {
            if (!string.IsNullOrEmpty(item.ParentName))
            {
                item = _Controller.GetUrlRewriteItem(item.ParentName);

                if (item == null)
                {// item not found, return
                    return(output);
                }

                if (!this.ShowRootNode && string.IsNullOrEmpty(item.ParentName))
                {// don't render the root node
                    return(output);
                }

                // insert link
                output.Insert(0, @"<a" + (string.IsNullOrEmpty(LinkCssClass) ? ("") : (@" class=""" + LinkCssClass + @""""))
                              + @" href=""" + ResolveUrl((item.Url + item.Path).Replace("//", "/")) + @""">" + (string.IsNullOrEmpty(item.BreadcrumbTitle) ? ResolveUrl(item.FullVirtualPath) : item.BreadcrumbTitle) + @"</a>");

                if ((string.IsNullOrEmpty(item.ParentName) && this.ShowFirstSeparator) ||
                    (!string.IsNullOrEmpty(item.ParentName)))
                {
                    // insert separator
                    if (!string.IsNullOrEmpty(this.VirtualSeparatorImageUrl))
                    {
                        output.Insert(0, "<img alt=\"\" border=\"0\" src=\"" + ResolveUrl(this.VirtualSeparatorImageUrl) + "\"/>");
                    }
                    else
                    {
                        output.Insert(0, "<span" + (string.IsNullOrEmpty(SeparatorCssClass) ? ("") : (@" class=""" + SeparatorCssClass + @"""")) + ">" + Separator + "</span>");
                    }
                }

                return(GetBreadcrumbs(output, item));
            }

            return(output);
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormattedRedirectRule"/> class.
 /// </summary>
 /// <param name="item">The item.</param>
 public FormattedRedirectRule(IUrlRewriteItem item)
 {
     Init(item.Name, item.Url, item.Vanity, item.Pattern, item.Path);
 }
예제 #4
0
 /// <summary>
 /// Resolves the rewrite item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="host">The host (www.mysite.com).</param>
 /// <param name="context">The current context.</param>
 /// <param name="control">The sending control control.</param>
 /// <param name="args">The args to format the resulting string with.</param>
 /// <returns>
 /// A resolved url path, string.Empty if an error occurred
 /// </returns>
 public static string ResolveRewriteItem(HttpContext context, Control control, string host, IUrlRewriteItem item, params object[] args)
 {
     return(ResolveItem(host, context, control, item, args));
 }
예제 #5
0
 /// <summary>
 /// Resolves the rewrite item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="context">The current context.</param>
 /// <param name="control">The sending control control.</param>
 /// <returns>
 /// A resolved url path, string.Empty if an error occurred
 /// </returns>
 public static string ResolveRewriteItem(HttpContext context, Control control, IUrlRewriteItem item)
 {
     return(ResolveItem(null, context, control, item));
 }
예제 #6
0
 /// <summary>
 /// Resolves the rewrite item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="args">The args to format the resulting string with.</param>
 /// <returns>
 /// A resolved url path, string.Empty if an error occurred
 /// </returns>
 public static string ResolveRewriteItem(IUrlRewriteItem item, params object[] args)
 {
     return(ResolveItem(null, null, null, item, args));
 }
예제 #7
0
 /// <summary>
 /// Resolves the rewrite item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>
 /// A resolved url path, string.Empty if an error occurred
 /// </returns>
 public static string ResolveRewriteItem(IUrlRewriteItem item)
 {
     return(ResolveItem(null, null, null, item));
 }
예제 #8
0
        /// <summary>
        /// Resolves the rewrite item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="host">The host (www.mysite.com).</param>
        /// <param name="context">The current context.</param>
        /// <param name="control">The sending control control.</param>
        /// <param name="args">The args to format the resulting string with.</param>
        /// <returns>
        /// A resolved url path, string.Empty if an error occurred
        /// </returns>
        private static string ResolveItem(string host, HttpContext context, Control control, IUrlRewriteItem item, params object[] args)
        {
            string resolvedPath = string.Empty;

            if (context == null)
            {
                context = HttpContext.Current;
            }

            if (context != null)
            {
                if (control == null)
                {
                    control = context.CurrentHandler as Control;
                }

                if (control != null)
                {
                    if (item.IsHttps)
                    {
                        resolvedPath = string.Format("https://{0}{1}", string.IsNullOrEmpty(host) ? context.Request.Url.Host : host, control.ResolveUrl(item.FullVirtualPath));
                    }
                    else
                    {
                        resolvedPath = control.ResolveUrl(item.FullVirtualPath);
                    }

                    if (args != null && args.Length > 0)
                    {
                        resolvedPath = string.Format(resolvedPath, args);
                    }
                }
            }

            return(resolvedPath);
        }