假设有一个动作:
public ActionResult DoStuff([CustomAttribute("foo")]string value) {
// ...
}
有没有办法在 ModelBinder 中解析 value 的 CustomAttribute 实例?我看了 MVC 的源代码,很可能是我做错了,但当我试图复制他们检索复杂模型的 BindAttribute 的代码时,调用 GetAttributes() 并没有返回我要找的属性。
DefaultModelBinder
GetTypeDescriptor(controllerContext, bindingContext).GetAttributes();