当前位置 > 首页 > Asp.net

ASP.NET MVC的Razor引擎:RazorView

9/5/2012 8:12:00 AM来源:Asp.net

Razor引擎具有两个核心的类型,一个是表示View本身的类型RazorView,另一个则是获取和创建它的WebFormViewEngine,我们将用两篇文章对它们分别进行剖析。Razor引擎下的View通过类型RazorView表示,它与表示Web Form引擎View的类型WebFormView都是BuildManagerCompiledView的子类。[本文已经同步到《How ASP.NET MVC Works?》中]

目录
一、BuildManagerCompiledView
二、RazorView
三、实例演示:自定义View模拟RazorView的View呈现机制

一、BuildManagerCompiledView

为了能够清楚地说明实现在BuildManagerCompiledView中的View激活与呈现机制,我们列出了BuildManagerCompiledView中与此相关的内部和受保护的成员。

   1: public abstract class BuildManagerCompiledView : IView
   2: {   
   3:     internal IViewPageActivator ViewPageActivator;
   4:   
   5:     protected BuildManagerCompiledView(ControllerContext controllerContext, string viewPath);
   6:     protected BuildManagerCompiledView(ControllerContext controllerContext, string viewPath, IViewPageActivator viewPageActivator);
   7:     internal BuildManagerCompiledView(ControllerContext controllerContext, string viewPath, IViewPageActivator viewPageActivator, IDependencyResolver dependencyResolver);
   8:    
   9:     public void Render(ViewContext viewContext, TextWriter writer);
  10:     protected abstra