orchard-route

Orchard路由解析1

DefaultOrchardShell类

DefaultOrchardShell中跟路由相关的就是Active函数。看代码:

1
2
3
var allRoutes = new List<RouteDescriptor>();
//注册的时候 只有 Orchard.Setup.Routes这个类
allRoutes.AddRange(_routeProviders.SelectMany(provider => provider.GetRoutes()));//SellContainerFactory中注册到容器

然后再通过routePublisher 加入RouteCollection集合

1
2
3
4
5
6
7
8
//封装成ShellRoute对象
//传入shellSettings
var shellRoute = new ShellRoute(routeDescriptor.Route, _shellSettings, _workContextAccessor, _runningShellTable) {
IsHttpRoute = routeDescriptor is HttpRouteDescriptor,
SessionState = sessionStateBehavior
};
//_routeCollection 为RouteTable.Routes
_routeCollection.Add(routeDescriptor.Name, shellRoute);

publish的时候会先对RouteArray排序,根据Priority

1
2
3
var routesArray = routes
.OrderByDescending(r => r.Priority)
.ToArray();

模块的RouteBase对象都封装成ShellRoute对象,以后都在ShellRoute中解析。

接下来我们来看看安装完后 首页是如何定位到Controller的。

欢迎关注我的公众号:沉迷Spring
显示 Gitment 评论
0%