コード例 #1
0
        public static Route MapRouteUnderline(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");
            }
            // 注意:
            //       1. 这里使用的 Route 是 UnderlineRoute
            //       2. 这里使用的 RouteHandler 是 UnderlineMvcRouteHandler
            UnderlineRoute item = new UnderlineRoute(url, new UnderlineMvcRouteHandler())
            {
                Defaults    = new RouteValueDictionary(defaults),
                Constraints = new RouteValueDictionary(constraints),
                DataTokens  = new RouteValueDictionary(namespaces)
            };

            if (namespaces != null && namespaces.Length > 0)
            {
                item.DataTokens["Namespaces"] = namespaces;
            }
            routes.Add(name, item);
            return(item);
        }
コード例 #2
0
 protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
 {
     UnderlineRoute.ReplaceUnderlineToSubtractionSignInRouteData(requestContext); // 调用 UnderlineRoute 类处理
     return(base.GetHttpHandler(requestContext));
 }