使用MyGeneration创建模板:介绍(翻译)

本教程详细介绍了如何使用MyGeneration开发模板创建基本的JScript或VBScript模板,包括创建模板、填写属性、保存模板、编写UI接口代码、测试接口、输入模板代码以及执行模板的过程。此外,教程还提供了完成模板执行后的HTML页面展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文信息

系统需求:

  • Microsoft Windows 2000/XP
  • Microsoft .Net Framework 1.1/更高
  • MDAC 2.7/更高
  • MyGeneration

概观

这是一个使用 MyGeneration 开发模板的基本的介绍。如果你安装了 MyGeneration ,并且对 MyGeneration 感到迷惑的话,这里是一个很好的教你使用 MyGeneration 的教程。这个教程将教会你使用 MyGeneration 创建基本的 JScript 或 VBScript 的模板。

创建模板

    • 打开 MyGeneration
    • 从菜单中选择File->New->JScript Template或者File->New->VBScript Template 
      填充模板属性
    • 你可以通过点击 Property 按钮查看或编辑模板的属性 
      按照如下的显示填充属性窗体

保存模板

  • 选择File->Save As...保存模板

输入UI接口代码

通过切换到Interface Code的Tab页面,可以编辑接口代码。这里的接口代码在运行时,将会生成一个窗体,提示用户输入一个名称,而用户输入的名称将会替换掉“Hello World”中的World。

JScript

 1 //In the interface code segment, the setup function 
 2  //is the initial function call.
 3  function setup()
 4  {
 5         //Set the form title bar to say "Hello World!!"
 6         ui.Title = "Hello World!!";
 7 
 8 
 9         //Set the height and width of the form in pixels
10         ui.Height = 150;
11         ui.Width = 340;
12 
13 
14         //Add a label and a textbox to the form.
15         ui.AddLabel("lblName", "Enter a Name:", "Enter a name below");
16         ui.AddTextBox("txtName", "World", "Enter a name in here");
17 
18 
19         //The number of times to repeat "Hellow World!!"
20         input.item("timesToRepeat") = 10;
21 
22 
23         //Tells MyGeneration to display the form. If this is 
24         //set to false. MyGeneration skips displaying the
25         //form, but retains any changes made in the interface
26         //code segment.
27         ui.ShowGUI = true;
28  }

VBScript

 1 'In the interface code segment, the setup function 
 2  'is the initial function call.
 3  Sub setup()
 4         'Set the form title bar to say "Hello World!!"
 5         ui.Title = "Hello World!!"
 6 
 7 
 8         'Set the height and width of the form in pixels
 9         ui.Height = 150
10         ui.Width = 340
11 
12 
13         'Add a label and a textbox to the form.
14         ui.AddLabel "lblName", "Enter a Name:", "Enter a name below"
15         ui.AddTextBox "txtName", "World", "Enter a name in here"
16 
17 
18         'The number of times to repeat "Hellow World!!"
19         input.item("timesToRepeat") = 10
20         'Tells MyGeneration to display the form. If this is 
21         'set to false. MyGeneration skips displaying the
22         'form, but retains any changes made in the interface
23         'code segment.
24         ui.ShowGUI = true
25  End Sub

测试UI接口

如果你想测试一下前面输入的内容的结果,你就需要执行模板。点击工具栏的Execute按钮(绿色的播放按钮),你将看到如下的结果

输入模板代码

通过切换到Template Code Tab页,可以查看和编辑模板代码。如下的代码将生成一个显示10各Hello Name!!!的HTML页面。

JScript

1 <html>
2         <body>
3  <% for (var i = 0; i < input.item("timesToRepeat"); i++) { %>
4                         <br>Hello <%= input.item("txtName") %>!!
5  <% } %>
6         </body>
7  </html>

VBScript

1 <html>
2         <body>
3  <% For i = 0 to input.item("timesToRepeat") %>
4                         <br>Hello <%= input.item("txtName") %>!!
5  <% Next %>
6         </body>
7  </html>

执行完成的模板

  • 执行模板之前,保存模板
  • 点击执行按钮,执行后的结果如下:
 1  <html>
 2         <body>
 3                         <br>Hello World!!
 4                         <br>Hello World!!
 5                         <br>Hello World!!
 6                         <br>Hello World!!
 7                         <br>Hello World!!
 8                         <br>Hello World!!
 9                         <br>Hello World!!
10                         <br>Hello World!!
11                         <br>Hello World!!
12                         <br>Hello World!!
13         </body>
14  </html>

结束语

希望通过这个教程,你看到了 MyGeneration 通过你的指尖在键盘上的敲打而显现的强大的力量。当你开始熟悉 MyGeneration 之后,我建议你做如下的事情:

    1. 查看安装 MyGeneration 时附带的模板,我从哪儿学到了很多;
    2. 研究 Zeus 的API文档以及 MyMeta ;
    3. 思考一下,在你的工作中哪些需要使用 MyGeneration ,发现这些,你将会吃惊的发现,以前很多耗时的工作, MyGeneration 会使它们变得轻而易举。

 

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/qiernonstop/p/3763113.html

MyGeneration 是一款不错的ORM和代码生成工具,它基于模板(Template)工作,安装好MyGeneration 后自带了很多模板,并且提供在线模板库提供模板升级和允许用户自定义模板MyGeneration模板可以用C#, VB.NET, JScript, and VBScript编写。使用MyGeneration 可以为Gentle.NET, Opf3, NHibernate等生成ORM架构或ORM文件,为多种数据库生成存储过程,为.Net项目生成C#、VB.NET 程序代码,PHP、HTML等页面代码。 MyGeneration 具有以下的特性: 1.支持多种数据库 Microsoft SQLServer Oracle IBM DB2 Microsoft Access MySQL PostgreSQL Firebird Interbase SQLite VistaDB Advantage IBM iSeries CSV & other delimited text files 2.支持重用和include文件 3.Ability to single step through all templates regardless of language. (单步调试?) 4.支持为模板输入自定义用户界面,包括winForm程序。 5.提供cmd命令行工具(ZuesCmd.Exe)和GUI(Project)工具. 6.提供强大的原数据 API(MyMeta)访问你的数据库里的原数据。 7.提供Unicode、语法高亮、查找、替换等功能的强大文本编辑器。 8.支持插件(Intrinsic Objects)扩展模板的功能。 9.支持MyMeta meta-data providers插件 10.Dockable windows.(不懂) 11.提供动态的可重写的数据类型映射。从数据库类型到MyGeneration的数据提供者类型到代码类型。 12.支持用户自定义原数据。 13.支持表、字段名、参数等重命名。 14.可以使用Gentle.NET, Opf3, NHibernate的模板。 15.支持在线帮助、模板升级和论坛。 二、myGeneration里的文件 目录: Architectures\ Contains dOOdads and any other MyGeneration sponsered frameworks/architectures. GeneratedCode\ 默认生成代码的存放位置。 Settings\ 配置文件存放目录。配置文件是各种.xml文件。 Templates\ 默认模板存放目录。 可执行文件: MyGeneration.exe 打开window界面 ZeusCmd.exe 打开命令行界面 uninstall.exe 各种帮助文件: ~\.chm 各种数据库驱动文件: ~\.dll 配置文件: DockManager.Config Settings\DefaultSettings.xml 存放默认设置。 Settings\DbTargets.xml 存放数据库到数据提供者数据类型的映射配置 Settings\Languages.xml 存放数据提供者到目标语言的数据类型映射配置 Settings\ScintillaNET.xml 存放语法高亮显示的对应关系的设置信息。 Settings\ZeusConfig.xml 三、缺点 只支持单表,复杂的查询还要先写视图
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值