Rebuilding Web Api programs (Api Controller and Entity) (2), apientity
A good generation of programs have been modified and reconstructed several times. In this article, Insus. NET does not find it perfect and concise to modify and refactor the previous part.
When we modify or delete an existing json file, we read data from the file, modify or delete the data, and then store the data. However, file operations are complicated. For example, you have to rename the file name to the old one before determining whether the file exists.
For these questions, Insus. NET decided to reconstruct the OrderEntity. cs class.
Open the JsonUtility. cs class and add the other two return value functions public staticString GenericListToJson <T> (List <T> listT)And public staticList <T> JsonToGenericList <T> (string json):
Then several methods in OrderEntity. cs can reference the above two functions:
After this modification, we can see that this class, several private methods or functions, has become 0 references:
Since there is no reference in the program, we can also delete them.
This class is restructured as follows: