Orchard 控制器解析1
CompositionStrategy类
CompositionStrategy中跟控制器相关的就是Compose函数。看代码:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 var allRoutes = new List<RouteDescriptor>();
var controllers = BuildBlueprint(features, IsController, BuildController, excludedTypes);
//通过Feature设置AreaName
private static ControllerBlueprint BuildController(Type type, Feature feature) {
var areaName = feature.Descriptor.Extension.Id;
var controllerName = type.Name;
if (controllerName.EndsWith("Controller"))
controllerName = controllerName.Substring(0, controllerName.Length - "Controller".Length);
return new ControllerBlueprint {
Type = type,
Feature = feature,
AreaName = areaName,//AreaName在这里加上 便于后面 ControllFactory中去寻找
ControllerName = controllerName,
};
}
ShellContainerFactory类:
然后再通过ShellContainerFactory 加入orchard容器中
1 | foreach (var item in blueprint.Controllers) { |
OrchardControllerFactory
然后控制器工厂OrchardControllerFactory类通过RouteData寻找Controller
路由数据就是在ShellRoute中找到匹配的路由数据
1 | protected override Type GetControllerType(RequestContext requestContext, string controllerName) { |