No head, no tail - Project Development Notes: How to Develop Code Update Tools ?! (on)

zhaozj2021-02-16  53

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:

// ** ?? Already use the TryandCatch.xml template document? ** //

// ** It is strictly forbidden to modify the following code ** //

// INSERT TRYTRY

// ** It is strictly forbidden to modify the above code ** //

// ** It is strictly forbidden to modify the following code ** //

// Insert Try

Try {

// ** It is strictly forbidden to modify the above code ** //

// ** It is strictly forbidden to modify the following code ** //

// INSERT CATCHCATCH

// ** It is strictly forbidden to modify the above code ** //

// ** 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 ** //

In the above XML template file, there are two sections: 1. The content representative of the middle of the section is not the content of this template has been implanted in the target code file, if the target code file is not found in the target code file The contents of the TemplateTag>, can be judged that the target has not been implanted with the code of this template, then uses the contents of the content in ; if you find the contents in the section in the target code file, you can It is judged that the target already implanted the code of this template, then uses the contents of in . 2. The content in each CodeSession stores previously implanted code, which requires an implanted code. The previously valued code is placed in , this time the code that needs to be implanted is placed in . When you need to replace the code, you can only need to modify the template file (copy the contents of the original ) to , and then you need newly implanted code into section), Once again, the code update tool is re-executed. (Sedent) http://www.9cbs.net/develop/Article/16/16309.shtm)

转载请注明原文地址:https://www.9cbs.com/read-24198.html

New Post(0)