コード例 #1
0
        private static void AddRoute(RouteCollection routes, string parentCategory, string childCategory, RouteAction act, string pluralChildCategory = "", bool isLowRest = true)
        {
            if (!string.IsNullOrEmpty(pluralChildCategory))
            {
                RouteNames.pluralResourceNames.Add(parentCategory, pluralChildCategory);
            }

            string childCategoryName = RouteNames.GetChildResourceName(childCategory, act);
            string action            = string.Empty;
            string route             = GetNestedRouteUrl(parentCategory, childCategory, act, out action, pluralChildCategory,
                                                         isLowRest);



            string route_name = RouteNames.GetNestedRouteName(parentCategory, childCategoryName, act, isLowRest);

            //AddLog(parentCategory + "/" + action + "->" + route + "/" + route_name);
            _routeNameToRoute.Add(route_name, routes.MapRouteWithName(
                                      route_name,                                           // Route name
                                      route,                                                // URL with parameters
                                      new { controller = parentCategory, action = action }, // Parameter defaults
                                      new { httpMethod = new HttpMethodConstraint(GetHttpVerb(act)) }
                                      ));
        }