Grouping routes also by name

This commit is contained in:
Sebastien Ros
2013-11-27 11:44:52 -08:00
parent 0cce4b4357
commit 654c432365
2 changed files with 10 additions and 4 deletions

View File

@@ -14,12 +14,14 @@ namespace Orchard.Mvc.Routes {
private readonly ConcurrentDictionary<string, IList<RouteBase>> _routesByShell = new ConcurrentDictionary<string, IList<RouteBase>>();
public HubRoute(string area, int priority, IRunningShellTable runningShellTable) {
public HubRoute(string name, string area, int priority, IRunningShellTable runningShellTable) {
Priority = priority;
Area = area;
Name = name;
_runningShellTable = runningShellTable;
}
public string Name { get; private set; }
public string Area { get; private set; }
public int Priority { get; private set; }
@@ -87,6 +89,10 @@ namespace Orchard.Mvc.Routes {
return 0;
}
if (String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(other.Name) || Name == other.Name) {
return 0;
}
if (!String.Equals(other.Area, Area, StringComparison.OrdinalIgnoreCase)) {
return StringComparer.OrdinalIgnoreCase.Compare(other.Area, Area);
}

View File

@@ -59,7 +59,7 @@ namespace Orchard.Mvc.Routes {
_routeCollection
.OfType<HubRoute>()
.ForEach(x => x.ReleaseShell(_shellSettings));
// new routes are added
foreach (var routeDescriptor in routesArray) {
// Loading session state information.
@@ -102,11 +102,11 @@ namespace Orchard.Mvc.Routes {
return false;
}
return routeDescriptor.Priority == hubRoute.Priority && hubRoute.Area.Equals(area, StringComparison.OrdinalIgnoreCase);
return routeDescriptor.Priority == hubRoute.Priority && hubRoute.Area.Equals(area, StringComparison.OrdinalIgnoreCase) && hubRoute.Name == routeDescriptor.Name;
}) as HubRoute;
if (matchedHubRoute == null) {
matchedHubRoute = new HubRoute(area, routeDescriptor.Priority, _runningShellTable);
matchedHubRoute = new HubRoute(routeDescriptor.Name, area, routeDescriptor.Priority, _runningShellTable);
int index;
for (index = 0; index < _routeCollection.Count; index++) {