public string GetRouteDescriptorKey(HttpContextBase httpContext, RouteBase routeBase) {
            var route = routeBase as Route;
            var dataTokens = new RouteValueDictionary();

            if (route != null) {
                dataTokens = route.DataTokens;
            }
            else {
            var routeData = routeBase.GetRouteData(httpContext);

                if (routeData != null) {
                    dataTokens = routeData.DataTokens;
                }
            }

            var keyBuilder = new StringBuilder();

            if (route != null) {
                keyBuilder.AppendFormat("url={0};", route.Url);
            }

            // the data tokens are used in case the same url is used by several features, like *{path} (Rewrite Rules and Home Page Provider)
            if (dataTokens != null) {
                foreach (var key in dataTokens.Keys) {
                    keyBuilder.AppendFormat("{0}={1};", key, dataTokens[key]);
                }
            }

            return keyBuilder.ToString().ToLowerInvariant();
        }
示例#2
0
 protected RequestContext NewRequestContext(RouteBase route, FakeHttpContext httpContext)
 {
     RouteData routeData = route.GetRouteData(httpContext);
     return routeData != null ? new RequestContext(httpContext, routeData) : null;
 }