Given the popularity of CodeSmith and its templating markup language I decided to give it a try. Eventually I put together a set of templates which code-gen the following:
To produce these templates, I’ve gone through the official docs from A to Z, as well as bevy of samples found on blogs. I was looking for common patterns of implementation, so the templates represent my best shot.
For example, in an event handler of a behavior control you will probably manipulate the associated element. In a client control you will probably allow the caller to add their own event handlers, so you won’t need to manipulate the associated element yourself. These are general cases, and you certainly don’t have to follow them by the book, but that’s the kind of boilerplate code the templates generate.
Download templates and watch the video (safe for work; no dancing strippers, I promise) from the CodeSmith Gallery.
I’d like to thank Eric Smith’s crew for a free license of CodeSmith. Learning its markup language is a breeze and there are plenty of templates “out of the box” and up on the web site.
Also, big thanks to TechSmith for a free license of Camtasia which allowed me to put together the screencast. It’s amazing what this product can do!