Vb. NET writes semi-automatic initialization classes for smart devices

Source: Internet
Author: User

First, the introduction

For developers of NCF (NET Compact Edition), there are generally only two ways to save application options:

1. Write the value of the option to the registry, but if all applications write a large number of values to the registry it will eventually result in the registry consuming system resources and affecting the efficiency of the system, and this is why many software have to be reinstalled after the device is rebooted. This practice is not recommended in accordance with the idea of "procedure as independent as possible" in the context of modern procedure writing.

2, the option value as an initialization file to save, so that you can maximize the avoidance of system resource consumption, improve the independence of the program operation, this practice is personally considered preferable scheme. And this approach is very simple in the. NET full edition and can be implemented directly with XML serialization classes. However, in the Net Compact Edition tailored for smart mobile devices, saving and using program options becomes depressing because the XML serialization attribute is not provided. Program developers have to write/read the file encoding for each program option, and this tedious step is never an interesting thing.

Second, functional overview

In this article, I'll build a class that automates the save/Read and write of initialization files with the reflection capabilities of. Net. In this class, as long as the author of the program defines the internal member variables of the class within the class by the name of the program option (as this step still requires the programmer to do the manual coding within the class), so this class is called a semi-automatic initialization class, and this class automatically saves/reads the program option from the initialization file, Programmers no longer have to do the tedious coding of the read and write file portions. Also, the build of this class can have a benefit: because the application's options are stored inside the class as member variables, programmers can query the options for initializing files by using the function of the automatically listing variable members provided by VS. For example, write String Myappname= tobjAPPOption.General.APPName. As far as I know, it's not fun to remember the exact characters of a lot of program options Oh 8-)

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.