private void setView(MethodInfo method) { if (this.GetType().IsSubclassOf(method.DeclaringType)) { String filePath = MvcUtil.getParentViewPath(method, ctx.route.getRootNamespace(method.DeclaringType.FullName)); this.utils.setCurrentView(this.utils.getTemplateByFileName(filePath)); } else { view(method.Name); } }
//------------------------------------------------------------------------ private void setControllerView(ControllerBase controller, MethodInfo actionMethod) { // 控制器继承 if (actionMethod.DeclaringType != controller.GetType()) { String filePath = MvcUtil.getParentViewPath(actionMethod, controller.ctx.route.getRootNamespace(actionMethod.DeclaringType.FullName)); controller.utils.setCurrentView(controller.utils.getTemplateByFileName(filePath)); } else { controller.view(controller.ctx.route.action); } }
private String runCurrentLayout(ControllerBase controller, MvcContext ctx, ProcessContext context, String actionContent) { MethodInfo layoutMethod = controller.utils.getMethod("Layout"); if (layoutMethod.DeclaringType != controller.GetType()) { String filePath = MvcUtil.getParentViewPath(layoutMethod, ctx.route.getRootNamespace(layoutMethod.DeclaringType.FullName)); controller.utils.setCurrentView(controller.utils.getTemplateByFileName(filePath)); } else { controller.utils.switchViewToLayout(); } controller.actionContent(""); // 清理当前内容,否则下面的utils.getActionResult()得不到正确结果 controller.Layout(); return(controller.utils.getActionResult()); }