One of the tutorials for the latest codesmith3.2 (. net2.0): codesmith introduction and guide

Source: Internet
Author: User
1. First recognized codesmith
To know how powerful codesmith is, I 'd like to tell you the best way to try it. Although codesmith has many advanced and even complex functions, however, you don't have to master all these functions to use them to generate Code .

In this chapter, you will learn how to use codesmith to generate a piece of useful code-a strongly typed hash table class. Follow me to ensure that you can complete it in less than five minutes, in addition, you can see the powerful functions of codesmith explorer and codesmith studio to generate template code.

2. Start codesmith Explorer

The first step is to start codesmith explorer, just like the function of Windows Explorer to organize folders stored on your computer. The main function of codesmith explorer is to organize template files, start your codesmith Explorer through Select Start> Programs> codesmith 3.0> codesmith explorer. Some sample templates are included in the initial interface of codesmith explorer.

3. Open a template

The template shows the code generation style. codesmith provides some useful basic templates. You can also use the codesmith support site
Download to more templates. You can also use codesmith to develop your own templates.

First, click the plus sign of the root directory folder

Files with the CST extension are the codesmith templates. You may have guessed their general purpose from the names of these templates. For example, the cshashtable. CST template is used to generate the C # hash table class. Double-click the template (or right-click and select execute) to open it.

4. Set attributes

If a code generator generates the same code every time, it will be useless. Of course, if you just treat it as a code memory, it will be another matter. Codesmith can customize attributes for you to generate custom code. When you open a template file using codesmith explorer, the template properties page displays the attributes required by the template. Before codesmith generates code, you must enter the values of these parameters. The cshashtable template requires four string attributes (classname, classnamespace, itemtype, and keytype) and an enumeration type attribute (Accessibility ).. You can enter any value you want for a string type attribute, and you can only select the corresponding value for the enumerated type attribute through the drop-down menu. As the first attempt, we enter the following values:

 

the biggest advantage of codesmith is that it can define different types of metadata attributes. For example, you can create a database form attribute so that users can select a table in the database and generate code. The features of codesmith in creating database table attributes will be described in later sections.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.