public override void Process(string templateName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext) { string fileName = GetFileName(templateName); IViewBaseInternal view; view = GetView(fileName, output, context, controller, controllerContext); if (controllerContext.LayoutNames != null) { string[] layoutNames = controllerContext.LayoutNames; for (int i = layoutNames.Length - 1; i >= 0; --i) { string layoutName = layoutNames[i].Trim(); IViewBaseInternal layout = GetLayout(layoutName, output, context, controller, controllerContext); layout.ContentView = view; view = layout; } } if (controller != null) { controller.PreSendView(view); } view.Process(); if (controller != null) { controller.PostSendView(view); } }
protected void SetLayout(Type layoutType) { IViewBaseInternal layout = (IViewBaseInternal)Activator.CreateInstance(layoutType); InitializeView(layout); layout.ContentView = view; view = layout; }
/// <summary> /// Initializes a new instance of the <see cref="ViewComponentContext"/> class. /// </summary> /// <param name="callingView">The calling view.</param> /// <param name="body">The body.</param> /// <param name="name">The name.</param> /// <param name="parameters">The parameters.</param> public ViewComponentContext(IViewBaseInternal callingView, ViewComponentSectionRendereDelegate body, string name, IDictionary parameters) { this.callingView = callingView; this.body = body; componentName = name; componentParameters = parameters; }
private static string GetFrom(IViewBaseInternal view, OutputMethod output) { string actual; using (var writer = new StringWriter()) using (view.SetDisposeableOutputWriter(writer)) { output.Invoke(); actual = writer.GetStringBuilder().ToString(); } return(actual); }
public override void Process(string templateName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext) { // Get the main, entry-point, view instance IViewBaseInternal view = GetView(templateName, output, context, controller, controllerContext); // create layout views if needed. The entry point is changed to the outer-most layout. // each layout on the way holds its containing layout on the ContentView property, // down to the original entry-point. if (controllerContext.LayoutNames != null) { var layoutNames = controllerContext.LayoutNames; for (var i = layoutNames.Length - 1; i >= 0; --i) { var layoutName = layoutNames[i].Trim(); IViewBaseInternal layout = GetLayout(layoutName, output, context, controller, controllerContext); layout.ContentView = view; view = layout; } } if (controller != null) { controller.PreSendView(view); } // initialize the entry point view.Initialize(this, output, context, controller, controllerContext, null); // initialize inner layouts down to the original entry-point var parent = view; var backtraceLayoutsToMainView = view.ContentView; while (backtraceLayoutsToMainView != null) { backtraceLayoutsToMainView.Initialize(this, output, context, controller, controllerContext, parent.Properties); parent = backtraceLayoutsToMainView; backtraceLayoutsToMainView = parent.ContentView; } InitializeViewsStack(context); // process the view view.Process(); if (controller != null) { controller.PostSendView(view); } }
protected void InitializeView(IViewBaseInternal viewInstance) { viewInstance.Initialize(engine, writer, context, controller, controllerContext); }
protected void InitializeView(Type viewType) { view = (IViewBaseInternal)Activator.CreateInstance(viewType); InitializeView(); }
protected void InitializeView(IViewBaseInternal viewInstance) { viewInstance.Initialize(engine, writer, context, controller, controllerContext, null); }
public ReturnOutputStreamToInitialWriter(TextWriter initialWriter, IViewBaseInternal view) { this.initialWriter = initialWriter; this.view = view; }
private static string GetFrom(IViewBaseInternal view, OutputMethod output) { string actual; using (StringWriter writer = new StringWriter()) using (view.SetDisposeableOutputWriter(writer)) { output.Invoke(); actual = writer.GetStringBuilder().ToString(); } return actual; }
/// <summary> /// Initializes a new instance of the <see cref="ViewComponentContext"/> class. /// </summary> /// <param name="callingView">The parent.</param> /// <param name="body">The body.</param> /// <param name="name">The name.</param> /// <param name="arguments">The arguments.</param> public ViewComponentContext(IViewBaseInternal callingView, ViewComponentSectionRendereDelegate body, string name, params object[] arguments) : this(callingView, body, name, Utilities.ConvertArgumentsToParameters(arguments)) { }