Setting Properties
A code generator that generated the exact same code every time wouldn't be very useful (you might as well just paste in a saved code file, if that's what you want). CodeSmith templates use properties to let you customize the generated code. When you open a template from CodeSmith Explorer, the template's property sheet shows you all of the properties that the template requires. You need to supply values for these properties before CodeSmith can generate the code for you. The CSHashTable template requires four string properties (ClassName, ClassNamespace, ItemType, and KeyType) and one enumerated property (Accessibility). You can type any value you like for a string property; an enumerated property presents you with a drop-down list of choices when you click in it. For this first experiment, fill out the property sheet this way:
One of the best things about CodeSmith is that properties can be based on many different types of metadata. For instance, you can create a property that presents a list of all of the tables in a database, letting the user choose a table when they're generating the code. You can learn more about this in the section on Driving Templates with Metadata.
Next: Generating Code