private RouteData GetRouteData() { var routeData = new RouteData(); RouteExtensions.ApplyCurrentPath(routeData, "WebForms", "Index", webContext.CurrentPath); return(routeData); }
private ContentRegistration AnalyzeView(HttpContextBase httpContext, VirtualFile file, string controllerName, Type modelType) { if (modelType == null || !typeof(ContentItem).IsAssignableFrom(modelType) || modelType.IsAbstract) { return(null); } var model = Activator.CreateInstance(modelType) as ContentItem; var rd = new RouteData(); bool isPage = model.IsPage; RouteExtensions.ApplyCurrentPath(rd, controllerName, Path.GetFileNameWithoutExtension(file.Name), new PathData(isPage ? model : new StubItem(), isPage ? null : model)); var cctx = new ControllerContext(httpContext, rd, new StubController()); var result = isPage ? viewEnginesProvider.Get().FindView(cctx, file.VirtualPath, null) : viewEnginesProvider.Get().FindPartialView(cctx, file.VirtualPath); if (result.View == null) { return(null); } return(RenderViewForRegistration(file, modelType, cctx, result)); }
private static HtmlHelper CreateHtmlHelper(ContentItem item, TextWriter writer) { var httpContext = new HttpContextWrapper(HttpContext.Current); var routeData = new RouteData(); RouteExtensions.ApplyCurrentPath(routeData, "WebForms", "Index", new PathData(item.ClosestPage(), item)); return(new HtmlHelper( new ViewContext( new ControllerContext() { HttpContext = httpContext, RequestContext = new RequestContext(httpContext, routeData), RouteData = routeData }, new WebFormView(HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath), new ViewDataDictionary(), new TempDataDictionary(), writer), new ViewPage(), RouteTable.Routes)); }
private HtmlHelper BuildHtmlHelper() { var ctx = new HttpContextWrapper(Context); var rd = new RouteData(); var currentPage = (Page is IItemContainer) ? (Page as IItemContainer).CurrentItem : N2.Context.CurrentPage; RouteExtensions.ApplyCurrentPath(rd, "WebForms", "Index", new PathData(currentPage, currentPage)); rd.DataTokens[ContentRoute.ContentEngineKey] = N2.Context.Current; var rqctx = new RequestContext(ctx, rd); var ctrlctx = new ControllerContext { HttpContext = ctx, RequestContext = rqctx, RouteData = rqctx.RouteData }; var wfv = new WebFormView(ctrlctx, Request.CurrentExecutionFilePath); var vctx = new ViewContext(ctrlctx, wfv, new ViewDataDictionary(), new TempDataDictionary(), Response.Output) { RouteData = rd }; return(new HtmlHelper <ContentItem>(vctx, new ViewPage())); }