Generating Code

When you've finished setting properties for the template, you're ready to generate code. To do this, click the Generate button at the bottom of the template's property sheet. CodeSmith Generator will take the property values that you entered and combine them with the template to create the code, and display it in an output window. The generated code can be edited by typing in the generated output window. You can also easily copy or save the generated text by clicking on the respected buttons at the top of the output window.

In this case, the code window contains around 320 lines of generated code for the hash table class, implementing the IDictionary, ICollection, IEnumerable, and ICloneable interfaces. There's nothing there that you couldn't write yourself if you're a reasonably experienced C# developer - but why bother? This is the sort of routine work that CodeSmith Generator is ideally suited for. With CodeSmith Generator, you can devote your time and energy to identifying patterns in your code, turning them into templates, and then reuse them with maximum flexibility in the future.

Next: Inspecting the Template

Advanced: Using a CodeSmith Generator Project to Execute CodeSmith Templates from Anywhere.