Rebuilding Web Api programs (Api Controller and Entity) (2), apientity

Source: Internet
Author: User

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:


Related Article

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.