(original) Object-oriented system docking interface programming. 3rd article

Source: Internet
Author: User

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


Tell me about Factory.cs. Factory class





usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceZgmz. UIL. app{/// <summary>    ///app feature Portal/// </summary>     Public classFactory {PrivateFactory () {}Private StaticFactory Factory =NewFactory (); /// <summary>        ///App Factory/// </summary>        /// <returns></returns>         Public StaticFactory appfactory () {returnFactory; }        /// <summary>        ///return: User Action portal/// </summary>        /// <returns></returns>         PublicZgmz. UIL. App.User.Index Getuserfacade () {returnZgmz. UIL.        App.User.Index.GetInstance (); }        /// <summary>        ///back to: News operation Portal/// </summary>        /// <returns></returns>         PublicZgmz. UIL. App.News.Index Getnewsfacade () {returnZgmz. UIL.        App.News.Index.GetInstance (); }        /// <summary>        ///back to: brand Operation Portal/// </summary>        /// <returns></returns>         PublicZgmz. UIL. App.Brand.Index Getbrandfacade () {returnZgmz. UIL.        App.Brand.Index.GetInstance (); }        /// <summary>        ///return: Common method Operation Entry/// </summary>        /// <returns></returns>         PublicZGMZ.UIL.App.Common.Index Getcommonfacade () {returnZGMZ.UIL.App.Common.Index.GetInstance (); }        /// <summary>        ///back to: group Operation Portal/// </summary>        /// <returns></returns>         PublicZgmz. UIL. App.Group.Index Getgroupfacade () {returnZgmz. UIL.        App.Group.Index.GetInstance (); }    }}

Code Commentary:
Private Factory () {} declares that this is a private constructor and cannot be instantiated externally
public static Factory Appfactory () returns the instantiated object of Factory. This is a static one, and once instantiated, it will remain in memory for the lifetime, without having to repeatedly create and release instances.
Public ZGMZ. UIL. App.User.Index Getuserfacade () take the operating inlet of each module. Returns the instance object of the module. For example, this code returns the instance object of the user module. After the interface is usually to invoke the user-related parts, all from the factory entrance into. There won't be a 2nd entrance.



Next Code.cs file:





usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceZgmz. UIL. app{/// <summary>    ///The returned code collection/// </summary>    /// <creator>Zhiyuan Ma</creator>     Public Sealed classCode {PrivateCode () {}/// <summary>        ///Message ID/// </summary>        /// <author>Zhiyuan Ma (Marc)</author>         Public stringCodeid {Get;Private Set; } /// <summary>        ///Message Description/// </summary>         Public stringDescription {Get;Private Set; } /// <summary>        ///constructor Function/// </summary>        /// <param name= "ProductType" ></param>        /// <author>Zhiyuan Ma (Marc)</author>         PublicCode (stringCodeid,stringdescripion) {             This. Codeid =Codeid;  This. Description =descripion; }         Public Static ReadOnlyCode Success =NewCode (" -","Success"); #region200 Error Series is basic Public Static ReadOnlyCode Fail =NewCode (" $","failed");  Public Static ReadOnlyCode Failactionisnull =NewCode ("201","The parameter action must");  Public Static ReadOnlyCode failactionisnotexists =NewCode ("202","parameter action value is incorrect");  Public Static ReadOnlyCode Failhttpmethoderror =NewCode ("203","HTTP request is not in the correct manner");  Public Static ReadOnlyCode Failparameterformatisnotvalid =NewCode ("204","parameter format is incorrect");  Public Static ReadOnlyCode Failparameterisnull =NewCode ("205","parameter not assigned value");  Public Static ReadOnlyCode faildeserialize =NewCode ("206","deserialization failed");  Public Static ReadOnlyCode Failentityisnotget =NewCode ("207","Object Not acquired");  Public Static ReadOnlyCode failentityisexists =NewCode ("208","Data already exists");  Public Static ReadOnlyCode failmoreentity =NewCode ("209","more than one record exists"); #endregion        #regionThe 300 error series is about the user's Public Static ReadOnlyCode failmobileisregisted =NewCode (" -","Mobile phone number already registered"); #endregion         Public Static ReadOnlyCode Failserver =NewCode (" -","Server Internal Error"); }}

The code is elaborate:
This Code.cs file, the function is one: Define the corresponding message code and description.

Public sealed class Code declares that it cannot be inherited.
Private Code () {} declares that the class is private and cannot be instantiated externally.
public string Codeid {get; private set;} Defines a property accessor for a message code.
public string Description {get; private set;} Defines a property accessor for a message description.
Public Code (String Codeid, String descripion) defines a constructor
public static readonly Code Success = new Code ("100", "success"); Then there is a series of custom message codes. This code means that a message code of 100 is agreed upon. What he said meant "success".

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. 3rd 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.