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

推荐订阅源

Help Net Security
Help Net Security
Recent Announcements
Recent Announcements
A
About on SuperTechFans
N
News and Events Feed by Topic
I
Intezer
B
Blog
GbyAI
GbyAI
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
T
Troy Hunt's Blog
TaoSecurity Blog
TaoSecurity Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
The Register - Security
The Register - Security
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
P
Privacy & Cybersecurity Law Blog
S
Secure Thoughts
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
Google Developers Blog
罗磊的独立博客
博客园 - 聂微东
G
GRAHAM CLULEY
AWS News Blog
AWS News Blog
Google Online Security Blog
Google Online Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
C
Check Point Blog
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Spread Privacy
Spread Privacy
O
OpenAI News
T
Tor Project blog
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Attack and Defense Labs
Attack and Defense Labs
L
LINUX DO - 最新话题
Forbes - Security
Forbes - Security
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
S
Securelist
博客园_首页

博客园 - 四眼蒙面侠

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 11: View Page Activator 【转】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
四眼蒙面侠 · 2011-01-25 · via 博客园 - 四眼蒙面侠

Model Binders

ASP.NET MVC 1.0 introduced the IModelBinder interface. Developers who implement this interface are responsible for creating models from values obtained from value providers. In ASP.NET MVC 3, we introduced a new interface (IModelBinderProvider) which allows developers to dynamically provide implementations of IModelBinder. We have made IModelBinderProvider instances 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.

Implementing IModelBinderProvider

In prior versions of MVC, developers could only register static mappings from types to model binder instances (throughModelBinders.Binders). While this satisfied simple uses, it made complex and powerful model binders a little more challenging to write.

When we decided to open model binding up for dependency resolution, we knew that we were going to need to introduce a layer of indirection, since model binders are usually only valid for a limited number of types (unless you are the default model binder).

We solved both problems by introducing a new interface:

public interface IModelBinderProvider {
    IModelBinder GetBinder(Type modelType);
}

Developers who implement this interface can optionally return an implementation of IModelBinder for a given type (they should return null if they cannot create a binder for the given type).

The system continues to rely on a “default model binder” if the system cannot find any appropriate model binder for the given type. You can change the default model binder by setting ModelBinders.Binders.DefaultBinder. Out of the box, this is set to an instance of DefaultModelBinder.

There are no implementations of IModelBinderProvider in MVC. However, there is a similar system in MVC Futures from MVC 2 (in the ModelBinding folder), and there are several model binder providers that could be used to spark ideas about writing providers for MVC 3, including model binder providers for arrays, binary data, collections, complex objects, and dictionaries.

Location: IModelBinderProvider

This is a “multiply registered” style service introduced in MVC 3. The static registration point for this service is at ModelBinderProviders.BinderProviders for non-DI users.

The logic in ModelBinderProviderCollection (which implements ModelBinderProviders.BinderProviders) consults the dependency resolver, calling GetSerivces(typeof(IModelBinderProvider)) and adding any services found to the list of statically registered services. Model binder provides are run in-order, with a “first one to provide a model binder wins” strategy, so registration order is important. The providers found in the dependency resolver will always run in the order they are returned from the resolver (and before the static registered providers).

What’s Next?

Next up we’ll look at the new Controller Activator service.