예제 #1
0
        public static string RenderView(this DirectControllerAction controllerAction, IView view)
        {
            var stringWriter = new StringWriter();

            controllerAction.RenderView(view, stringWriter);
            return(stringWriter.ToString());
        }
예제 #2
0
        public static string RenderView(this DirectControllerAction controllerAction, string viewName, string masterName)
        {
            var stringWriter = new StringWriter();

            controllerAction.RenderView(viewName, masterName, stringWriter);
            return(stringWriter.ToString());
        }
예제 #3
0
        public static string RenderView(this DirectControllerAction controllerAction, Stream contentStream)
        {
            var stringWriter = new StringWriter();

            controllerAction.RenderView(contentStream, stringWriter);
            return(stringWriter.ToString());
        }
예제 #4
0
        public static void RenderView(this DirectControllerAction controllerAction, Stream contentStream, TextWriter writer)
        {
            var actionName     = controllerAction.ActionDescriptor.ActionName;
            var controllerName = controllerAction.ActionDescriptor.ControllerDescriptor.ControllerName;
            var virtualPath    = string.Format("~/Views/{0}/{1}.cshtml", controllerName, actionName);

            var view = new RazorViewSimulator(controllerAction.MvcApplication, new StreamVirtualContent(virtualPath, contentStream));

            controllerAction.RenderView(view, writer);
        }
예제 #5
0
        public static void RenderView(this DirectControllerAction controllerAction, IView view, TextWriter writer)
        {
            var controllerContext = controllerAction.CreateControllerContext();

            controllerContext.HttpContext.Response.Output = writer;

            var viewResult = new ViewResult
            {
                View = view,
                ViewEngineCollection = controllerAction.MvcApplication.ViewEngines
            };

            viewResult.ExecuteResult(controllerContext);
        }
예제 #6
0
 public static ViewResultSimulator <TModel> View <TModel>(this DirectControllerAction controllerAction, ActionExecutionContext executionContext, IVirtualContent virtualContent, TModel model)
 {
     return(new ViewResultSimulator <TModel>(executionContext, virtualContent, model));
 }
예제 #7
0
 public static ViewResultSimulator <object> View(this DirectControllerAction controllerAction, IVirtualContent virtualContent)
 {
     return(new ViewResultSimulator <object>(controllerAction.GetExecutionContext(), virtualContent, null));
 }