Socancode7 template compilation

Source: Internet
Author: User
Document directory
  • 1.1. databasejson
  • 1.2. settingjson

The software uses JavaScript as a template. The software divides the database and configuration items into JSON as parameters, calls the main function of the template entry, and returns an array.

 

Template example:

 

/**

* Function entry

*/

Function main (databasejson, settingjson ){

VaR Codes = new array ()

 

Codes. Push ({Title: 'error', path: 'error.txt ', code:' template is not complete yet. '});

 

Return codes;

}

1. The input parameter format is 1.1. databasejson

{

"Connstring": "Data Source = 127.0.0.1, 7788; user id = sa; Password =; initial catalog = test ;",

"Name": "test ",

"Type": "SQL2000 ",

"Selects ":[

{

"Name": "tbl_item ",

"Isview": false,

"Fields ":[

{

"POS": 1,

"Name": "Itemid ",

"Isid": True,

"Iskey": false,

"Size": 4,

"Length": 10,

"Allownull": false,

"Defaultvalue ":"",

"Descn": "Itemid ",

"Fieldtype": "int"

},

{

"POS": 2,

"Name": "typeid ",

"Isid": false,

"Iskey": false,

"Size": 4,

"Length": 10,

"Allownull": false,

"Defaultvalue ":"",

"Descn": "typeid ",

"Fieldtype": "int"

},

{

"POS": 3,

"Name": "roleid ",

"Isid": false,

"Iskey": false,

"Size": 4,

"Length": 10,

"Allownull": false,

"Defaultvalue ":"",

"Descn": "roleid ",

"Fieldtype": "int"

},

{

"POS": 4,

"Name": "createtime ",

"Isid": false,

"Iskey": false,

"Size": 8,

"Length": 23,

"Allownull": True,

"Defaultvalue ":"",

"Descn": "createtime ",

"Fieldtype": "datetime"

}

]

}

]

}

1.2. settingjson

[

{

"Name": "cacheframe ",

"Description": "cache structure ",

"Value": "objectcache"

},

{

"Name": "blframe ",

"Description": "business layer style ",

"Value": "BLL"

},

{

"Name": "commandtype ",

"Description": "database read/write mode ",

"Value": "SQL"

},

{

"Name": "filterdefaultablefield ",

"Description": "whether to filter fields with default values ",

"Value": "false"

},

{

"Name": "dbhelpername ",

"Description": "dbhelpername ",

"Value": "dbhelper"

},

{

"Name": "dalframe ",

"Description": "Dal project name ",

"Value": "Dal"

},

{

"Name": "modelstyle ",

"Description": "entity layer style ",

"Value": "CS3"

},

{

"Name": "slnframe ",

"Description": "three-layer structure style ",

"Value": "simple"

},

{

"Name": "namespacesuffix ",

"Description": "namespace suffix ",

"Value ":""

},

{

"Name": "namespaceprefix ",

"Description": "namespace prefix ",

"Value ":""

},

{

"Name": "vsversion ",

"Description": "Visual Studio version ",

"Value": "2010"

}

]

2. Return Value

The main function returns an array by passing in databasejson and settingjson. Each element in the array is in JSON format and can be in the following two forms:

 

1. copy a file (folder)

{

Type: 'copy', // type is copy

Isfolder: True, // whether it is a folder copy

Source: 'Folder \ model', // File Source Path, relative to the template path address

Target: 'model' // target path, relative to the output path

}

 

2. Output code

{

Type: 'code', // The type is code, which can be omitted

Title: 'model-internal', // used to display the code in the title when it is generated

Path: 'Folder \ test. CS ', // file path when code is output

Code: 'console. Write ("Hello, world"); '// code to be output

}

3. Notes

1. The template settings use the XML format.

2. Generating code will load all JS files under the Template

3. Call the main function when generating code. The main function is the entry function.

4. You can view the input parameters in the "wipe" Window of the software.

5. by using the "add template" function of the software, four files are automatically generated, including helper. JS is an auxiliary function that contains a practical function for template writing; dbtype. JS is a method for adding the dbtype attribute to the field. It can convert various database types to the dbtype corresponding to C #. to modify the type of the generated field, you can modify this file.

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.