惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
The Hacker News
The Hacker News
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
IT之家
IT之家
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
AI
AI
罗磊的独立博客
B
Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Check Point Blog
D
DataBreaches.Net
T
Threat Research - Cisco Blogs
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
MongoDB | Blog
MongoDB | Blog
P
Privacy & Cybersecurity Law Blog
Cisco Talos Blog
Cisco Talos Blog
P
Privacy International News Feed
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园_首页
I
Intezer
云风的 BLOG
云风的 BLOG
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
美团技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
腾讯CDC
T
Troy Hunt's Blog
Know Your Adversary
Know Your Adversary
U
Unit 42

博客园 - 四眼蒙面侠

BMAD Loop:把开发循环的控制权,交还给确定性代码 从 Agent 到代码:Claude Code 编排模型的演进 BMAD Story Automator 上手实录:把 5 个待办 Story 交给 AI 自主推进 深入 SwiftWork(第 0 篇):用 SwiftUI 构建一个 Agent 可视化工作台 深入 Open Agent SDK(番外篇):实战验证——把 SDK 塞进一个 macOS 原生 Agent 应用 深入 Open Agent SDK(六):多 LLM 提供商与运行时控制 深入 Open Agent SDK(五):会话持久化与安全防线 深入 Open Agent SDK(四):多 Agent 协作——子代理、团队与任务编排 深入 Open Agent SDK(三):MCP 集成实战——让 Agent 连接万物 深入 Open Agent SDK(二):34 个工具的背后——工具协议、三层架构与自定义扩展 深入 Open Agent SDK(一):Agent Loop 内核——从 prompt 到多轮对话的完整运转机制 Open Agent SDK (Swift):用原生 Swift 构建 AI Agent 应用 BMAD开发效率翻倍: 一条命令交付整个Epic BMad v6实战过程全公开:32场对话揭秘人机协作怎么搞? AutoQA-Agent:用 Markdown 写验收用例,AI + Playwright 跑起来,跑通还能导出成 Playwright Test 我在Claude Code状态栏养了一个电子宠物 ccshell – 基于Claude Code的自然语言Shell命令工具 用 Planet + ENS 构建一个真正去中心化的博客 BMAD-METHOD:让一个人顶一个敏捷团队的 AI 驱动开发框架 Claude Code 深夜也要加班?这个神器让 AI 自动续命! 告别脆弱的 Playwright 测试:为什么基于 YAML 的测试是未来趋势 来个好玩的,用手机随时随地指挥你的 Cursor! 开源一个练手小App, PrintableCheckList Swift 和 C# 的语法比较 发布一个基于newsyc修改的StartupNews的iOS客户端 (PHP)使用Behat和Mink对Web应用做BDD(行为测试驱动开发) 微博应用--PC遥控器 正式开源 新浪微博小工具--PC遥控器1.0发布 Brad Wilson写的 ASP.NET MVC 3 Service Location 系列文章索引 【转】ASP.NET MVC 3 Service Location, Part 10: Controller Activator 【转】ASP.NET MVC 3 Service Location, Part 8: Value Providers 【转】ASP.NET MVC 3 Service Location, Part 9: Model Binders
【转】ASP.NET MVC 3 Service Location, Part 11: View Page Activator
四眼蒙面侠 · 2011-01-25 · via 博客园 - 四眼蒙面侠

View Page Activator

In ASP.NET MVC, it’s common for views to be compiled into classes. In MVC 1.0, we shipped the WebFormViewEngine as the default view engine, which allowed the user to write views using the familiar <% %> syntax from ASP.NET WebForms. The first time the view is rendered, the view file goes through a code generation step, which is compiled into a class. The WebFormViewclass is responsible for creating and executing the class that resulted from the view.

In ASP.NET MVC 3, we introduced a new Razor view engine. Like the WebForm view engine, the .cshtml and .vbhtml files from Razor go through a code generation step at run-time which compiles down into classes. The RazorView class is the Razor view engine counterpart to the WebFormView class.

We have introduced a new base class (BuildManagerCompiledView) and a new service (IViewPageActivator) which is responsible for instantiating instances of the view classes that were compiled from the view files. We have made the IViewPageActivator instance findable via the dependency resolver.

Disclaimer

This blog post talks about ASP.NET MVC 3 Beta, which is a pre-release version. Specific technical details may change before the final release of MVC 3. This release is designed to elicit feedback on features with enough time to make meaningful changes before MVC 3 ships, so please comment on this blog post or contact me if you have comments.

New Base Class: BuildManagerCompiledView

When we introduced the new Razor view engine, it was clear that there was a lot of common code between the infrastructure classes of our two view engines; namely, the WebFormView and RazorView (which both implement the IView interface) had significant shared code that was centered around BuildManager.

In the ASP.NET runtime, BuildManager is the class that is responsible for converting view files (like .aspx and .ascx files in WebForms, and .cshtml and .vbhtml files in Razor) into the underlying classes using code generation. BuildManager uses build providers to do most of that transformation work (which is outside the scope of this blog post). The important takeaway is that we extracted a common base class for the two view classes: BuildManagerCompiledView. The logic which creates view page class instances was centralized into this class, and the new IViewPageActivator service was introduced to allow pluggability of the creation of the view page classes.

Developers which are creating view engines which use build providers and BuildManager to convert view files into classes can take advantage of this new base class for their implementation(s) of the IView interface.

Implementing IViewPageActivator

The new IViewPageActivator interface contains a single method for creating a view page instance:

public interface IViewPageActivator {
    object Create(ControllerContext controllerContext, Type type);
}

Given the controller context and the view page class type, implementers of this interface must create the view page instance.

Location: IViewPageActivator

This is a “singly registered” style service introduced in MVC 3. There is no static registration point for this service as its purpose is strictly to support dependency injection; as such, the only way to register an instance of this service is through the dependency resolver.

The logic in BuildManagerCompiledView consults the dependency resolver, calling GetSerivce(typeof(IViewPageActivator)) and using the provided service when present. If there is no IViewPageActivator present in the dependency resolver, we will then ask the dependency resolver to create the concrete view page type by calling GetService(viewPageType). If the dependency resolver also fails to create the concrete view page type, we finally fall back to the MVC 2 behavior of using Activator.CreateInstance to create the view page type.

What's Next?

This is the end of the road for MVC 3 Beta. We believe we are now reasonably feature complete for MVC 3 and dependency resolution. If there are specific areas where you wish the framework would better enable dependency resolution, please don't hesitate to discuss them on the MVC Forums.

Thanks for reading!