WinForm Development Framework business object Unified Invocation method

Source: Internet
Author: User
Tags inheritance

In this complex society, the characteristics of unity can bring a lot of efficient output, solid memory, this feature regardless of the enterprise, personal development work, knowledge of the inheritance has a very important role, the WINFROM framework itself is based on this concept, from the unified database design rules began, The unified project pattern, unified business class, data access class, entity class inheritance relationship, then to the unified Common class library, the unified Rights Management module, the Unified Dictionary Management module, the unified attachment management ..., understand these ideas and rules, then come to a final unification, The framework code quickly generates--DATABASE2SHARP code generation tools. All of the framework (including the traditional WinForm development framework, WCF development Framework, Hybrid development Framework, Web development framework) are integrated here to unify all kinds of seemingly fragmented, but highly permeable modules, the pace of unification in addition to time, effectiveness, bring me more gifts. This article mainly introduces the way of unified invocation of business objects of my WinForm framework (also including other framework features), and introduces how to create various business objects through bllfactory or Callerfactory Common class library.

1. Uniform invocation rules for bllfactory objects

In my frame, all business class calls are started with the Bllfactory portal to create, passing business objects in to create, this unified way of entry can easily memory, and reduce code, more importantly, some such as caching rules, create rules to encapsulate, simplify the code. The Bllfactory sketch is shown below.

Now that the Bllfactory class library should be elevated to the level of the common class library, since it is the unified invocation rule approach, the common class libraries supported by the WinForm framework are shown below.

Of course, in order to reduce code, improve development efficiency, the overall framework embodies the rules of code reuse everywhere, as much as possible to extract duplicate code, so there are many such as data access base class, business access base class, data access base class interface, Entity base class class library, combined with generics can make our API more unified, strongly typed , improve the development efficiency. Because Bllfactory is a common class library level, all independently developed modules are also created with the same library as the unified portal to create the necessary objects.

Let's look at how the framework can create a series of objects exactly in a complex class library.

The code for the Bllfactory business Object Factory Helper class is shown below.

<summary>///factory class///</summary>///<typeparam name= "T" > Business object type for business class </typeparam&
    Gt
        public class bllfactory<t> where T:class {private static Hashtable Objcache = new Hashtable ();
    
        private static Object syncRoot = new Object (); 
            <summary>///Create or obtain an instance of the corresponding business class from the cache///</summary> public static T Instance { get {string cachekey = typeof (T).
                FullName;  T BLL = (t) Objcache[cachekey];
                        Read from cache if (BLL = = null) {lock (syncRoot) { if (BLL = = null) {BLL = Reflect<t>. Create (typeof (T). FullName, typeof (T). Assembly.getname (). Name); Reflection is created, and the Objcache.add (typeof (T) is cached.
                        FullName, BLL);
     }
                    }           return BLL; }
        }
    }

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.