コード例 #1
0
        /// <summary>
        /// 把路由集合的UrlRoute重写
        /// </summary>
        public static RewriteLowerCaseUrlRoute MapLowerCaseUrlRoute(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");
            }
            RewriteLowerCaseUrlRoute route2 = new RewriteLowerCaseUrlRoute(url, new MvcRouteHandler())
            {
                Defaults    = new RouteValueDictionary(defaults),
                Constraints = new RouteValueDictionary(constraints),
                DataTokens  = new RouteValueDictionary()
            };
            RewriteLowerCaseUrlRoute item = route2;

            if ((namespaces != null) && (namespaces.Length > 0))
            {
                item.DataTokens["Namespaces"] = namespaces;
            }
            routes.Add(name, item);
            return(item);
        }
コード例 #2
0
        /// <summary>
        /// 把区域路由的UrlRoute重写
        /// </summary>
        public static RewriteLowerCaseUrlRoute MapLowerCaseUrlRoute(this AreaRegistrationContext context,
                                                                    string name,
                                                                    string url,
                                                                    object defaults,
                                                                    object constraints,
                                                                    string[] namespaces)
        {
            if ((namespaces == null) && (context.Namespaces != null))
            {
                namespaces = context.Namespaces.ToArray();
            }
            RewriteLowerCaseUrlRoute route = MapLowerCaseUrlRoute(context.Routes, name, url, defaults, constraints, namespaces);

            route.DataTokens["area"] = context.AreaName;
            bool flag = (namespaces == null) || (namespaces.Length == 0);

            route.DataTokens["UseNamespaceFallback"] = flag;
            return(route);
        }