To get a deeper understanding and use of C #, we started this series of technical lectures on the "C # Discovery Tour". Given that most of you are in the Web database development, and the so-called discovery is found that we are unfamiliar with the field, so this series of lectures will be C # in the Web database development outside the application. The main content of the current planning is graphic development and XML development, and plans to organize a number of courses. In the next C # Discovery Tour, we follow the step-by-step steps to explore and discover the other unknown areas of C #, a deeper understanding and mastery of the use of C # for software development, broaden our horizons, enhance our comprehensive software development capabilities.
This course explains
Through previous studies, we have largely learned about XML/XSLT development, and in this course we will use C # in asp.net to develop a code builder based on XSLT technology.
Code generator
First, let's say what a code generator is. The individual thinks is a kind of tool software, it can according to some kind of already fixed information, use the program to the machine's large quantity generation to have the structure to have the relatively simple rule source code, thus reduces the software developer's coding quantity.
Broadly speaking, the Web database programs we write are code generators that automatically generate large amounts of HTML code based on fixed data stored in the database. Here we limit the code generator to a generic code generator. The main function of the code generator is to help programmers automatically generate a large number of low-level code, this code can be C # or Java program source code, can also be SQL statements, or HTML code, etc., is a software development process of the auxiliary tool software.
Our most commonly used code generators are automatically generated from the database structure to manipulate the database records of the program source code, SQL statements or other documents and so on. For this kind of code generator, its data information source is the database table structure and the field attribute and so on information, we can analyze the system table that traverses the database to the goods table structure and the field information, can also be obtained from the document which PowerDesigner and so on data structure designer saves.
For a particular project, we can temporarily write a code generator based on the database structure, using string patchwork to generate the source code, but this code generator is not generic and difficult to use for other projects. So we're more using a generic code generator.
Many common code generators are shown in the schematic diagram
In this diagram, we see that the code generator contains the template library and the code generator processing engine, and the template library contains several templates, a template that is generally plain text, which may contain scripting code, or a structure similar to that of an ASP. The builder engine loads one or more database table structure design information, and then invokes the user-specified template, which automatically generates another text file, which can be plain text, HTML code, C # code, or something else.
Examining this structure, we can see that this principle is very similar to that of the XSLT principle. We can save database table structure design information in an XML document, the code generator template uses XSLT format, the code generator engine uses the XSLT transformation engine, so that we can also achieve the function of the code generator, so that based on the XSLT code generator.