Quickly build your own code generator based on the agileeas.net SOA middleware domain Model data generator

Source: Internet
Author: User
Tags svn update

First, preface

The Agileeas.net SOA middleware platform is based on agile parallel development ideas and Microsoft. NET component (component) development technology and a rapid development application platform. To help small and medium-sized software enterprises to establish a rapid market change for the development team to achieve savings in development costs, shorten development time, quickly adapt to market changes.

The Agileeas.net SOA Middleware platform provides best practices for agile rapid development of software engineering by providing a large number of basic support functions such as the IOC, ORM, SOA, distributed architecture, and the plug-in development system supported by the agile concurrency development approach, as well as providing a large number of entities, Data model design generation tools, code generation tools to help small and medium-sized software developers grow rapidly.

Agileeas.net platform fully grasp the current rapid development of the software industry trends, based on agile parallel development, rapid adaptation to the market such simple software engineering practice, using the industry's widely used Microsoft. NET component (component) Development technology practices This kind of development idea, helps the software enterprise realize "the agile change, the quick fit" the goal, thus helps the software enterprise to win the opportunity in the intense market competition and obtains the higher return.

Ii. about the Domain Model designer

Agileeas.net SOA Middleware Platform has been working hard to provide a more convenient, easier and simpler development experience for the vast majority of programmers, so in addition to providing a variety of powerful class libraries such as containers, ORM, Linq, communications, SOA, message bus, etc. We also strive to provide an excellent set of development tools for the vast majority of programmers, including the domain model designers we consider to be the most valuable.

Agileeas.net SOA Middleware Platform Domain Model Designer provides a range of powerful features such as domain (database) modeling, database document generation, entity code (business or other code) generation, and DDL script generation.

The domain Model Designer supports not only the definition of a single model, but also the relationships between the various models, which currently support reference entities (similar to foreign key references), child entities (parent-child relationship) definitions, extended properties, and associative reference definitions of enumerated objects.


Application of Agileeas.net SOA middleware development, we advocate the use of priority to model design ideas, rather than the priority of database structure design, one is the idea above the model first, the other is after the completion of the model, the system can export database design documents, greatly reduce the duplication of tools, and can improve document efficiency.

Based on this approach can also ensure that the document and the database, code is strong consistent, does not produce documents and programs, and database is not the case, this situation in many many software enterprises should be common, control documents, code, database consistency is very expensive, using agileeas.net SOA Middleware platform Domain Model designer and the application of this idea can be a good solution to this problem.

The script that generates the model corresponding data table, currently supports SQL Server, ORACLE, Mysql, sqllite Four kinds of database, DLL script can be an object of one object generation, can also choose to uniformly build all the scripts in the solution.

code generation, generating corresponding model definition code, single model code and relationship between models, model and enumeration association.

The Domain Model Designer provides the capability of a direct output solution that directly generates a project or solution that can be directly hit by the VS development tool.

Third, the Domain Model Designer plug-in mechanism of the detailed

Agileeas.net SOA Middleware Platform Domain Model Designer in the use of many partners and community friends, we have received feedback from some customers and community friends to improve and improve, there are many community friends have such a demand, some friends have developed their own ORM framework, But it's very expensive to write a feature like our domain Model designer, so hopefully we can provide a plug-in mechanism to implement his own code generation capabilities, and some of our customers need to apply to some third-party products (such as a hospital-integrated ESB platform) in the project. These products also provide some two development features, in which there is a need to generate model definition code.

Based on a variety of feedback, we decided to provide plug-in functionality for the Agileeas.net SOA middleware platform domain model Designer to meet the needs of a variety of customer and community friends, currently we offer two plug-ins, one is code generation plug-in, and the other is a single interface plugin.

The code generation plug-in replaces the built-in code generation plug-in to generate its own variety of model code, which is used by the interface generation plug-in to handle solutions that are currently open.

To achieve this requirement, we define two interfaces:

Code generation plug-in interface ICodeGenerator:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceEAS. design{/// <summary>    ///The code generator interface, which is used to complete code generation. /// </summary>     Public InterfaceICodeGenerator {/// <summary>        ///The code scheme name. /// </summary>        stringName {Get; }        /// <summary>        ///Generates code for generating data table objects and table column information. /// </summary>        /// <param name= "rootentity" >table information. </param>        /// <param name= "Project" >work item information. </param>        /// <returns>generate code results. </returns>        stringGeneratcode (rootentity rootentity,project Project); /// <summary>        ///generates an enumeration object code. /// </summary>        /// <param Name= "Enumeration" >enumerates the objects. </param>        /// <param name= "Project" >work item information. </param>        /// <returns>generate code results. </returns>        stringGeneratcode (Enumeration enumeration, project project); /// <summary>        ///The output/build workaround. /// </summary>        /// <param name= "Project" >Item Metadata. </param>        /// <param name= "OutputFolder" >The output path. </param>        /// <param name= "Havesolution" >whether to build the solution. </param>        voidGeneratsolution (Project Project,stringOutputFolder,BOOLHavesolution =false); }}

The ICodeGenerator interface defines a Name property that returns the plug-in name, and the Generatcode method used to generate a single entity and enumeration, and later generates a generatsolution definition of the overall solution, to implement its own code-generation plug-in, You must implement this interface.

Interface plug-in interface Idesignaddin:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceEAS. design{/// <summary>    ///Meta Data Designer plug-in. /// </summary>     Public InterfaceIdesignaddin {/// <summary>        ///plug-in name. /// </summary>        stringName {Get; }        /// <summary>        ///executes the plug-in. /// </summary>        /// <param name= "Workproject" >The current project. </param>        voidStart (Project workproject); }}

Idesignaddin interface definition is relatively simple, in addition to the plug-in name definition, there is only a start method for processing the current solution project, in the domain Model Designer under the plug-in menu " column name casing switch " is a built-in Idesignaddin plugin with the following code:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingEAS. loggers;usingEAS. Design.codegenerator;namespaceEAS. design.ui{classColumnnameswaddin:eas. Design.idesignaddin {#regionIdesignaddin MembersstringIdesignaddin.name {Get            {                return "Column name Casing Toggle"; }        }         Public voidStart (Project workproject) {columnnameswform form=NewColumnnameswform (); Form. Project=Workproject; Form. StartPosition=Formstartposition.centerscreen; Form.        ShowDialog (); }        #endregion    }    Partial classColumnnameswform:form {InternalProject Project {Get; Set; }         PublicColumnnameswform () {InitializeComponent (); }        Private voidBtngenerat_click (Objectsender, EventArgs e) {            foreach(varIteminch  This. Project.rootentities) {if( This. rbupper.checked && This. cbtablename.checked &&!string. IsNullOrEmpty (item. maptable)) {item. Maptable=item.                Maptable.toupper (); }                Else if(! This. rbupper.checked && This. cbtablename.checked &&!string. IsNullOrEmpty (item. maptable)) {item. Maptable=item.                Maptable.tolower (); }                if( This. cbcolumnname.checked) {                    foreach(varColumninchitem. Properties) {if(string. IsNullOrEmpty (column. ColumnName)) column. ColumnName=column.                        Name; if( This. rbupper.checked) {column. ColumnName=column.                        Columnname.toupper (); }                        Else{column. ColumnName=column.                        Columnname.tolower (); } }}} MessageBox.Show ("the process is complete, please reopen the relevant model!","Tips", MessageBoxButtons.OK, messageboxicon.information);  This.        Close (); }    }}

Both interfaces and the data structures involved in the interface are defined by the exhaustion of the EAS.Metadata.dll assembly, where:

Project: The solution, including the entity, enumeration definition.

Rootentity: Entity module definition.

Enumeration: Enumerates the object definitions.

Iv. Code plug-in implementation, quickly build your own code generator

Previously, there was a friend of his own implementation of a domain Model designer code generation plug-in, used to generate Castle ActiveRecord entity code, and also willing to contribute to the implementation of the source, so we do a little explanation based on this.

To implement the code generation plug-in, we first build a class library project, and reference the EAS.Metadata.dll assembly, build a class and implement the ICodeGenerator interface, the project code structure is as follows:

After implementing the required properties and methods of the plug-in interface, we compile the code and copy the generated EAS.MetaDesign.CodeAddIn.AR.dll to the EAS.MetaDesigner.exe same directory, and open the Domain Model Designer for configuration.

After the design is complete, reopen the domain Model Designer, and we open an entity and we can see that the generated code has changed:

In the "output" = "Generate Code" menu subkey of the domain Model Designer, the "castle.ar" menu appears, which is used to output the entire solution code.

To this, we Nissan:

Download the example code

This article covers the domain Model designer code plug-in example, the source code has been placed in the latest version of Agileeas.net SOA middleware, please download through the Agileeas.net SOA middleware Platform official website, or download it by the following way:

Direct download: agileeas.net SOA 5.2 Download, Http://112.74.66.105/downloads/eas/agileeas.net.5.rar.

SVN update: https://112.74.66.105/svn/eas/5.0, login User: EAS, password eas.

Agileeas.net SOA Middleware Platform administrator: Administrator, login password sa.

The compressed package downloaded directly may have a time lag, that is, may not necessarily be the latest version, it is recommended that you download the latest version through SVN.

Vi. Contact Us

The Agile Software Engineering Laboratory has been established to improve, improve and promote agileeas.net and is a professional software provider for the research, promotion and development of new technologies and for the provision of business-based platform software with independent intellectual property rights, as well as the development of management software based on the Business Foundation platform. The main business is to provide customers with software enterprise research and development management solutions, enterprise management software development, as well as related technical support, management and technical advice and training business.

Agileeas.net platform since the fall of 2004, I have been gradually improved and improved, but also used in insurance, medical, e-commerce, real estate, railways, education and other applications, but has always been in my personal promotion, 2010 because I resigned to rest, I thought of putting agileeas.net on the market and getting more people to use it.

Technical team members are friends for many years, because this platform is free, our operating expenses mainly rely on providing consulting services to customers, we are all because of the programmer's ideals and beliefs persist, here I thank the struggling friends and always support our work customers, friends.

Team Site: http://www.agilelab.cn,

Agileeas.net Website: http://www.smarteas.net

Official blog: http://eastjade.cnblogs.com

qq:47920381

Agileeas.net QQ Group:

113723486 (Agileeas SOA platform)/maximum 2000 people

199463175 (agileeas SOA Exchange)/maximum 2000 people

116773358 (agileeas.net SOA platform)/maximum 2000 people

Email: [Email protected],[email protected],

Tel: 18629261335.

Quickly build your own code generator based on the agileeas.net SOA middleware domain Model data generator

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.