public static Route MapRouteLowerCase(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"); } Route route = new AttributeRoute(url, new RouteValueDictionary(defaults), new RouteValueDictionary(constraints), null, new Configuration { UseLowercaseRoutes = true, PreserveCaseForUrlParameters = true, }) { Defaults = new RouteValueDictionary(defaults), Constraints = new RouteValueDictionary(constraints), DataTokens = new RouteValueDictionary() }; if ((namespaces != null) && (namespaces.Length > 0)) { route.DataTokens["Namespaces"] = namespaces; } routes.Add(name, route); return(route); }
private static AttributeRoute CreateRoute( IRouter handler, IActionDescriptorCollectionProvider actionDescriptorProvider) { var constraintResolver = new Mock<IInlineConstraintResolver>(); constraintResolver .Setup(c => c.ResolveConstraint("int")) .Returns(new IntRouteConstraint()); var policy = new UriBuilderContextPooledObjectPolicy(new UrlTestEncoder()); var pool = new DefaultObjectPool<UriBuildingContext>(policy); var route = new AttributeRoute( handler, actionDescriptorProvider, constraintResolver.Object, pool, new UrlTestEncoder(), NullLoggerFactory.Instance); return route; }