Exemplo n.º 1
0
        public static SeoRoute MapRouteSeo(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            var route = new SeoRoute(url, new MvcRouteHandler())
            {
                Defaults    = new RouteValueDictionary(defaults),
                Constraints = new RouteValueDictionary(constraints)
            };

            route.DataTokens = route.DataTokens ?? new RouteValueDictionary();
            route.DataTokens.Add("RouteName", name);
            if ((namespaces != null) && (namespaces.Length > 0))
            {
                route.DataTokens["Namespaces"] = namespaces;
            }
            if (String.IsNullOrEmpty(name))
            {
                routes.Add(route);
            }
            else
            {
                routes.Add(name, route);
            }
            return(route);
        }
Exemplo n.º 2
0
        public static Route MapRouteSeo(this AreaRegistrationContext areaRegistrationContext, string name, string url, object defaults, object constraints, string[] namespaces)
        {
            if (areaRegistrationContext == null)
            {
                throw new ArgumentNullException("areaRegistrationContext");
            }
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            if (namespaces == null && areaRegistrationContext.Namespaces != null)
            {
                namespaces = areaRegistrationContext.Namespaces.ToArray();
            }

            SeoRoute route = areaRegistrationContext.Routes.MapRouteSeo(name, url, defaults, constraints, namespaces);

            route.DataTokens["area"] = areaRegistrationContext.AreaName;

            // disabling the namespace lookup fallback mechanism keeps areas from accidentally picking up
            // controllers belonging to other areas
            bool useNamespaceFallback = namespaces == null || namespaces.Length == 0;

            route.DataTokens["UseNamespaceFallback"] = useNamespaceFallback;

            return(route);
        }
Exemplo n.º 3
0
 public static SeoRoute MapRouteSeo(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces)
 {
     if (routes == null) { throw new ArgumentNullException("routes"); }
     if (url == null) { throw new ArgumentNullException("url"); }
     var route = new SeoRoute(url, new MvcRouteHandler()) {
         Defaults = new RouteValueDictionary(defaults),
         Constraints = new RouteValueDictionary(constraints)
     };
     route.DataTokens = route.DataTokens ?? new RouteValueDictionary();
     route.DataTokens.Add("RouteName", name);
     if ((namespaces != null) && (namespaces.Length > 0)) {
         route.DataTokens["Namespaces"] = namespaces;
     }
     if (String.IsNullOrEmpty(name)) { routes.Add(route); }
     else { routes.Add(name, route); }
     return route;
 }