(original) Object-oriented system docking interface programming. 4th article

Source: Internet
Author: User

Next: http://www.cnblogs.com/mazhiyuan/p/5224050.html

This article begins by writing the layout of the post and get requests.

Let's use the news module for example. Other modules, such as users, such as audio modules, leaf out, are the same.



Create a folder for the news module first. We're called "News."


Then, such as a total of three red circle. Create these 3 files.

Let's start with the 2nd document: CommandType.cs


CommandType.cs files, such as. He is an enumeration. It defines various business logic. For example, there is "add news". Here, let's take the example of adding news stories.
It is important to note that we have added the name of the news: Addappnews, then the name. You must have a corresponding. cs file. It's not a random writing.

Remember there is a picture above, there are 3 red circle? The name of the 1th red circle is called AddAppNews.cs. It is important to note that names must be identical. Then someone will ask, why? Because we use the reflective technology here. The name will then be reflected as a real. cs file: So it must be the same. If it is not the same, it will not be reflected.





The following is a Index.cs file. And the 3rd one in the red circle:


Code in detail, the use of a singleton mode. As for the singleton mode, I don't have to explain his code. So simple: lines 12th through 19th are all code for the singleton pattern. A total of 7 rows.

Public Basecommand createcommandinstance (CommandType type) This method uses a reflection technique. The enumeration of the above CommandType.cs is named, which is used here. The time will be reflected here.




Specific business: AddAppNews.cs file:


The code is elaborate:
public class Addappnews:post Add news, we use the POS request, so we want to inherit the Post base class.
The public addappnews () {} constructor must be public so that it can be reflected successfully.
public override void Excute () implements the business method of the base class Excute ()
Appnews appnews = this.    Deserialize<appnews> (); The protected T deserialize<t> () method in the base class Post.cs is used here. Do you remember this method? Don't remember to go back and look at it.





The above is the business process of the POST request. The processing of a GET request is listed below.
For example, we want to get news. Let's talk about get requests for news.


The code method, and the business logic for the POST request, such as AddAppNews.cs, are similar.
The difference is:
String useridreq = this.    input["UserID"]; This is the way he handles the arguments that pass over. such as a GET request, the request side sends a userid parameter. The URL that is usually requested is this: http://www....com/News.aspx?UserID=xxx

When you want to see this, there are 4 more: Here are the links:

(original) Multi-system needs docking, I wrote an interface framework. Practicality is very strong, write to everyone to communicate. Need to be able to move directly past use. (1th article) http://www.cnblogs.com/mazhiyuan/p/5224046.html

(original) Object-oriented system docking interface programming. 2nd article http://www.cnblogs.com/mazhiyuan/p/5224049.html

(original) Object-oriented system docking interface programming. 3rd article http://www.cnblogs.com/mazhiyuan/p/5224050.html

(original) Object-oriented system docking interface programming. 4th article http://www.cnblogs.com/mazhiyuan/p/5224054.html

(original) Object-oriented system docking interface programming. 5th (end) http://www.cnblogs.com/mazhiyuan/p/5224056.html

If read, have not understood can comment to me.

It's really good to use. There are students who need to do the interface. The entire frame can be used.

(original) Object-oriented system docking interface programming. 4th 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.