本文整理汇总了C#中IController.PreSendView方法的典型用法代码示例。如果您正苦于以下问题:C# IController.PreSendView方法的具体用法?C# IController.PreSendView怎么用?C# IController.PreSendView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IController
的用法示例。
在下文中一共展示了IController.PreSendView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
// Process a template name and output the results to the user
// This may throw if an error occured and the user is not local (which would
// cause the yellow screen of death)
public override void Process(String templateName, TextWriter output, IEngineContext context, IController controller,
IControllerContext controllerContext)
{
Log("Starting to process request for {0}", templateName);
string file = templateName + ViewFileExtension;
BrailBase view;
// Output may be the layout's child output if a layout exists
// or the context.Response.Output if the layout is null
LayoutViewOutput layoutViewOutput = GetOutput(output, context, controller, controllerContext);
// Will compile on first time, then save the assembly on the cache.
view = GetCompiledScriptInstance(file, layoutViewOutput.Output, context, controller, controllerContext);
if (controller != null)
{
controller.PreSendView(view);
}
Log("Executing view {0}", templateName);
RenderView(templateName, view);
layoutViewOutput.RenderLayouts(this, view);
Log("Finished executing view {0}", templateName);
if (controller != null)
{
controller.PostSendView(view);
}
}
示例2: PreSendView
/// <summary>
/// Invokes the <see cref="IController.PreSendView"/>
/// </summary>
/// <param name="controller">The controller.</param>
/// <param name="view">The view argument.</param>
protected virtual void PreSendView(IController controller, object view)
{
controller.PreSendView(view);
}
示例3: Process
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);
}
}
示例4: ProcessPartial
public override void ProcessPartial(string partialName, TextWriter output, IEngineContext context,
IController controller, IControllerContext controllerContext)
{
if (!initialized) Initialize();
Log("Generating partial for {0}", partialName);
try
{
string file = ResolveTemplateName(partialName);
BrailBase view = GetCompiledScriptInstance(file, output, context, controller, controllerContext, partialName);
TextWriter oldos = null;
string key = "";
bool fromcache = false;
if (controller != null)
{
controller.PreSendView(view);
}
Stopwatch sw = null;
if (options.CollectStatistics)
{
sw = Stopwatch.StartNew();
}
if (view.__isCacheable())
{
key = view.__getCacheKey();
if (_outputCache.ContainsKey(key))
{
view.OutputStream.Write(_outputCache[key]);
fromcache = true;
}
else
{
oldos = view.OutputStream;
view.SetOutputStream(new StringWriter());
}
}
if (!fromcache)
{
_renderp(partialName, view);
if (view.__isCacheable())
{
var content = view.OutputStream.ToString();
_outputCache[key] = content;
view.SetOutputStream(oldos);
view.OutputStream.Write(content);
}
}
if (options.CollectStatistics)
{
sw.Stop();
this.Statistics.Rendered(partialName, fromcache, sw.ElapsedTicks);
}
_renderp(partialName, view);
}
catch (Exception ex)
{
if (Logger != null && Logger.IsErrorEnabled)
{
Logger.Error("Could not generate JS", ex);
}
throw new MonoRailException("Error generating partial: " + partialName, ex);
}
}
示例5: Process
// Process a template name and output the results to the user
// This may throw if an error occured and the user is not local (which would
// cause the yellow screen of death)
public override void Process(String templateName, TextWriter output, IEngineContext context, IController controller,
IControllerContext controllerContext)
{
Log("Starting to process request for {0}", templateName);
string file = templateName + ViewFileExtension;
BrailBase view;
// Output may be the layout's child output if a layout exists
// or the context.Response.Output if the layout is null
LayoutViewOutput layoutViewOutput = GetOutput(output, context, controller, controllerContext);
// Will compile on first time, then save the assembly on the cache.
view = GetCompiledScriptInstance(file, layoutViewOutput.Output, context, controller, controllerContext,templateName);
Stopwatch sw = null;
if(options.CollectStatistics) {
sw = Stopwatch.StartNew();
}
TextWriter oldos = null;
string key = "";
bool fromcache = false;
if (controller != null)
{
controller.PreSendView(view);
}
if(view.__isCacheable()){
key = view.__getCacheKey();
if (_outputCache.ContainsKey(key))
{
view.OutputStream.Write(_outputCache[key]);
fromcache = true;
}
else
{
oldos = view.OutputStream;
view.SetOutputStream(new StringWriter());
}
}
if (!fromcache)
{
_render(templateName, layoutViewOutput, view);
if (view.__isCacheable())
{
var content = view.OutputStream.ToString();
_outputCache[key] = content;
view.SetOutputStream(oldos);
view.OutputStream.Write(content);
}
}
if(options.CollectStatistics) {
sw.Stop();
this.Statistics.Rendered(templateName,fromcache,sw.ElapsedTicks);
}
if (controller != null)
{
controller.PostSendView(view);
}
}
示例6: Process
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);
}
}