I wanted to make some quick follow-up points to my “Cool stuff in FubuCore No. 7: Model Binding” post:
Joshua Flanagan pointed out that I had an error in my description of how the ExpandEnvironmentVariablesAttribute works. I updated the post to correct the error, so you may want to check that out.
Also, when I wrote the post I wasn’t quite clear on the distinction among ValueConverter, IPropertyBinder, and IModelBinder. There appeared to be some overlap. After speaking with Jeremy Miller some more, he set me straight.
ValueConverter: For coercing values from one type to another. These should be somewhat lightweight (i.e. turn “True” into the Boolean True value). The raw values will come from the IRequestData bag.
IPropertyBinder: These are meant for binding properties on your models to something not in the IRequestData bag. That is, something that wasn’t posted to the server or found in your ASP.NET Request or the AppSettings, etc. Two examples of the type of data you would might want to bind to your models that aren’t in the IRequestData bag: 1.) the current logged-on user’s email address and 2.) the current time zone of the server.
IModelBinder: This is if you need something beyond binding model objects and properties to name/value pair data. You can apply IModelBinders to specific situations (like the EntityModelBinder I mentioned in the original post), or complete replacement of Fubu’s default, built-in StandardModelBinder. I think this is one area where Fubu’s model binding shines because it does NOT require a full replacement/override of huge swaths of the model binding framework to handle a one-off situation. You can do it piece by piece. However, it does have the flexibility to be completely replaced/swapped-out if you need to do something completely different than name/value pair binding.