// 0) path => Blog.Admin // 1) path => Blog // 2) path => "" private static String addLayoutPrivate(String path, String actionContent, MvcContext ctx, Boolean isLastLayout) { // String content = layoutCacher.getByPath( path ) // if( strUtil.HasText( content ) ) return HtmlCombiner.combinePage( content, actionContent ); ControllerBase controller = ControllerFactory.FindLayoutController(path, ctx); if (controller == null) { return(actionContent); } ctx.controller.utils.addHidedLayouts(controller); // 将controller中提到需要隐藏的控制器隐藏 if (ctx.controller.utils.isHided(controller.GetType())) { return(actionContent); } // 检查缓存 String cacheKey = null; if (MvcConfig.Instance.IsActionCache) { IActionCache actionCache = ControllerMeta.GetActionCache(controller.GetType(), "Layout"); cacheKey = getCacheKey(actionCache, ctx); if (strUtil.HasText(cacheKey)) { Object cacheContent = checkCache(cacheKey); if (cacheContent != null) { logger.Info("load from nsLayoutCache=" + cacheKey); return(HtmlCombiner.combinePage(cacheContent.ToString(), actionContent)); } } } controller.utils.switchViewToLayout(); ActionRunner.runLayoutAction(ctx, controller, controller.Layout); if (ctx.utils.isEnd()) { return(controller.utils.getActionResult()); } String actionResult = controller.utils.getActionResult(); // 加入缓存 if (MvcConfig.Instance.IsActionCache) { if (cacheKey != null) { addContentToCache(cacheKey, actionResult); } } return(HtmlCombiner.combinePage(actionResult, actionContent)); }
private String runOtherLayout(ControllerBase controller, MvcContext ctx, ProcessContext context, String actionContent) { ControllerBase layoutController = ControllerFactory.FindController(controller.LayoutControllerType, ctx); layoutController.utils.switchViewToLayout(); ActionRunner.runLayoutAction(ctx, layoutController, layoutController.Layout); return(layoutController.utils.getActionResult()); }
// 0) path => Blog.Admin // 1) path => Blog // 2) path => "" private static String addLayoutPrivate(String path, String actionContent, MvcContext ctx, Boolean isLastLayout) { ControllerBase controller = ControllerFactory.FindLayoutController(path, ctx); if (controller == null) { return(actionContent); } ctx.controller.utils.addHidedLayouts(controller); // 将controller中提到需要隐藏的控制器隐藏 if (ctx.controller.utils.isHided(controller.GetType())) { return(actionContent); } // 检查缓存 ActionCacheChecker ci = ActionCacheChecker.InitLayout(ctx, controller); Object cacheContent = ci.GetCache(); if (cacheContent != null) { logger.Info("load from nsLayoutCache=" + ci.CacheKey); return(HtmlCombiner.combinePage(cacheContent.ToString(), actionContent)); } controller.utils.switchViewToLayout(); ActionRunner.runLayoutAction(ctx, controller, controller.Layout); if (ctx.utils.isEnd()) { return(ctx.utils.getCurrentOutputString()); } String actionResult = controller.utils.getActionResult(); if (ci.IsActionCache) { ci.AddCache(actionResult); } return(HtmlCombiner.combinePage(actionResult, actionContent)); }