Model Binder

When working with a multi-tier application I often find myself converting from one of the tiers object models to my own similar (but often different) model. I often write code that would set one by one each property from a web tier object to my object. In order to make this easier I wrote this object binder. It is a fake deep copy in a way. You tell it what destination type you want to build and give it a source object and it will go through each property (matching by names) and checks if it can copy from that property from the source to the destination. If it can’t it will call itself again on that object to try to copy its properties.

One possible enhancement I thought about was to add a attribute to indicate on the destination model that is maps to a property of a different name. I haven’t had a need for it yet but I will surely add it when I do.