A Quick Follow-up on Model Binding in FubuCore

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.

Related Articles:

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

About Chad Myers

Chad Myers is the Director of Development for Dovetail Software, in Austin, TX, where he leads a premiere software team building complex enterprise software products. Chad is a .NET software developer specializing in enterprise software designs and architectures. He has over 12 years of software development experience and a proven track record of Agile, test-driven project leadership using both Microsoft and open source tools. He is a community leader who speaks at the Austin .NET User's Group, the ADNUG Code Camp, and participates in various development communities and open source projects.
This entry was posted in .NET, cool-stuff-in-fubu, fubucore, FubuMVC. Bookmark the permalink. Follow any comments here with the RSS feed for this post.