Technorati label: codesmith
, Ol_beta
, Tutorial
The best way to understand codesmith is to try. You can try to use codesmith before you know all of its features. In this section, you will learn how to use codesmith to generate a piece of useful utility code-especially a strongly typed hash table class. This work should take up to five minutes to complete, but will introduce you to codesmith explorer and codesmith studio, and show you the right to generate a template-based code solution in your codesmith.
One way to start a code generation session is the resource manager in codesmith. Just as the windows Resource Management Service organizes files and folders to be stored on a computer, codesmith Resource Service organizes templates. To select resource manager from the codesmith Startup Program menu in codesmith, select resource manager in codesmith. It displays the installed codesmith template.
A template is part of the code generation. You can use the codesmith template to generate code, or use codesmith to develop your own template.
The. CST file extension represents the "codesmith template". For example, the cshashtable. CST template generates the C # code of the hash table class. Double-click this template (or right-click and select execute) to open it.
The codesmith template uses attributes to allow you to customize the generated code. When you open the resource manager in a template codesmith, all the attributes displayed in the template's attribute table. You need to provide the values of these attributes, and then codesmith can generate code for you. The cshashtable template requires four string attributes (category, classnamespace, itemtype value and keytype) and one enumeration attribute. You can enter any value as the same as the string property. For the first experiment, enter the attribute table as follows:
Click Generate. The code generated based on the template and attributes is displayed on the right.
You can paste the code into your file, or click Save to save it.