December 31: The last day of 2002, the weather is good! ! I hope that every day is good weather next year, I also hope that all IT practitioners will have a happy new year, happy every day!
I haven't updated the project for a long time not because there is no progress in our project. But I want the final exam! depressed. Yesterday, I finally finished my best, I was most afraid. I finally reopen the project notix.
The last item of the project note has a friend asks us if it is automatically generated, how can I update? How to retain the generation code change section? This article is primarily to talk about this. If you don't understand the code generation tool, you can refer to the previous item notes.
http://www.9cbs.net/develop/author/netauthor/viktoryu/
The part written below is to implement the features mentioned in the "Exact Processing and Logging Code Automatic Generation" article, in fact, the process of joining or updating the code in a pile of web service code files as an example, explaining the code generation tool and The development and use of the code update tool. l The code special rule generated when generated
A code that uses the code generation tool to be implanted with the renewal after the entire file is modified. The most critical point is that your code update tool is the code that can locate this paragraph, and the generated code is not broken. The so-called destruction is that the generated code has been modified by each developer and cannot be updated using a unified rule. In other words, when you design the code to be implanted, you need to make fine split, so that the implanted code guarantees atomicity. This requires that when generating the code, you must add some corresponding rules to the code. This paper mainly discusses relatively simple code updates, and may also use not these special rules, will discuss complicated code updates, will make more detachable words for the rules of the generated code. In this case, the updated data can only update a pre-defined part and can retain other parts in the target code file.
l Code update principle and program
The following are the principles and programs of the code update from the input principles required by the code update, the principle of the code update, and the principle of the code update to be output. The process of the code update tool is two steps: The first step is to identify the part of the code to update in the updated file; the second step is to replace the new code to update the code to update. Here I use an XML format template file to log file basic information, updated code, and newly implanted code. Ø The input code update of the code update includes two parts: 2 Original file (directory) where the original file is stored, you can find all the files to be updated through the original file directory. For example, in the project I have participated, I put all the web service files in C: / INETPUB / WWWROOT / Projects, I want to modify all the berish named .asmx.cs (Web Service in our project) The C # used in the C # is developed, and the other specific situations can be found in the previous document). Then the original file is entered into c: / inetpub / wwwroot / projects, I will find all the web services files by traversing the directory structure, and perform the job update work. 2 Template file template files for code update provides the version of the updated code, the version of the newly implanted code, and the identity of this template file. Here is an example of my template file: TryandCatch.xml file: XML Version = "1.0" encoding = "GB2312"?>
TemplateTag>
// ** It is strictly forbidden to modify the following code ** //
// INSERT TRYTRY
// ** It is strictly forbidden to modify the above code ** //
oldsource>
// ** It is strictly forbidden to modify the following code ** //
// Insert Try
Try {
// ** It is strictly forbidden to modify the above code ** //
newsource>
Codesession>
// ** It is strictly forbidden to modify the following code ** //
// INSERT CATCHCATCH
// ** It is strictly forbidden to modify the above code ** //
oldsource>
// ** It is strictly forbidden to modify the following code ** //
// INSERT CATCHCATCH
}
Catch (CommONException E) {
Return E.ErrorObject;
}
Catch (Exception E) {
Try {
Throw New ExceptionHandler.comMonexception (e);
}
Catch (CommONExcept EE) {
Return Ee.ErrorObject;
}
}
Finally {
}
// ** It is strictly forbidden to modify the above code ** //
newsource>
Codesession>
CODETEMPLATE>
In the above XML template file, there are two sections: 1.