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; }
}
}