I read the source code of MVC 3 , trying to figure out what semantics I should adhere to if I override DefaultModelBinder.BindModel () or even implement IModelBinder.BindModel ().
It is not clear to me that the "state" of BindModel () should leave other objects as soon as this is done with its work. I am sure that it should return a value representing some interpretation of ValueProvider data, but what side effects should it have? For instance:
- Is there any MVC expectation regarding the bindingContext state passed to BindModel () * after * the method has completed?
- What if something should set IModelBinder.BindModel () in ModelMetadata? (DefaultModelBinder sets property metadata to its BindProperty () method, called by BindModel ().)
- Should I override DefaultModelBinder.BindModel () call ModelState.AddModelError () or BindProperty () override a more appropriate place (especially if I want to use the default DefaultModelBinder behavior as much as possible)?
DefaultModelBinder has so many semantics built into its plumbing that it makes redefinition of everything that seems very dangerous (i.e. I feel that I cannot redefine anything without violating the Liskov Principle ). Lack of documentation does not help.
source
share