Introduction JHRS WPF development framework basic library. This series of articles aims to record the use of WPF in the development of new medical projects. I feel that some of the norms must be unified and improve the efficiency of team development.
So I tossed such a half-hearted framework, the basis of the JHRS development framework. Class libraries, every project has some basic class libraries, but friends who see these fragmentary texts can join in and watch them. If it can help you, it would be an honor.
JHRS WPF development framework basic library
Following the previous WPF Enterprise Development Framework Construction Guide, I introduced a development framework built at work. In fact, I moved some code everywhere to make up such a shelf. I didn’t write a lot of code manually, and I spent time. In the process of integrating the code and running the program, it’s okay, less gossip; in addition, the name of the framework is not easy to pick, so it was named after JHRS.
JHRS basic class library
In the JHRS class library, some codes that are not related to the business but cannot be missing are mainly placed. In fact, for each project, there are more or less classes that need to be encapsulated, and these classes constitute each project’s Basic class library.
Common file helper classes, JSON serialization and deserialization classes, upload and download, network, encryption, reflection, etc.
The above picture is just some packages that have been used in the current source code, including JSON, extended classes, paging query requests, collections, reflections, etc.
For example, in the basic class library of JHRS, JSON is extended, the basic conversion class, if you want to serialize an object, you can directly call the ToJson method, as shown in the following code:object o = new object () ; var json = o. ToJson () ;
Deserialize json into an object and just call it like this.
For some data type conversion methods, such as string to number, it is well known to call the method Convert.ToInt32, or the method int.TryParse, you can encapsulate it again in the basic class library, because there may be conversion with Convert. Abnormal problem, and int.Tryparse has the problem of complicated code, because you need to write it like this.int result = 0 ;int. TryParse ( “rex3” , out result ) ;
Even if it is written using the new syntax, it does not seem so intuitive and elegant. Then the unified wording after encapsulation supports generics, and there will be no conversion errors. The following code is the new way of writing:”34534xd” .CastTo < int >() ;
When performing data type conversion, you can require team members to call the CastTo generic method uniformly, which can avoid some inadvertent mistakes.
This is the same as the first loyalty of the encapsulation framework, the ultimate goal is to unify, including the code style.
Reference relationship of the basic class library
In the current solution, the JHRS basic class library will not reference other projects. Of course, third-party components say otherwise. For example, JSON needs to reference Newtonsoft.Json through NuGet; if other projects are referenced in the current solution, then The original purpose of the basic class library is lost, because if you reference other projects, there may be a circular reference problem.
Therefore, from this point of view, the basic class library does not contain business processing, and does not reference other projects in the current solution, but can be referenced by any other project, so that the class library has already served as the function of the basic class library. Introduction JHRS WPF development framework basic library.
Write at the end
The basic class library does not contain any business functions, it is very convenient to write unit tests to test whether each method meets the expected behavior.
Some codes are directly cut and put into open source, you can also integrate your own basic class library in this way of organization. There are many basic libraries with more comprehensive functions on github, you can find them.
Related reading in this series
- WPF Enterprise Development Framework Building Guide (Revelation)
- Introduction JHRS WPF development framework basic library
- JHRS WPF framework reference library introduction
- WPF call Web API package of JHRS development framework
- Client portal project of JHRS development framework
- How to integrate the various subsystems of the JHRS development framework
- How to design a reasonable ViewModel base class in JHRS development framework
- Encapsulation of public component user control of JHRS development framework
- Some principles of cataloging documents followed by the recommendations of the JHRS development framework
- WPF data verification of JHRS development framework
- The solution of JHRS development framework’s ViewModel mutual parameter transfer and pop-up frame return parameter
- JHRS development framework of stepping on the pit (final chapter)
Introduction JHRS WPF development framework basic library.