代码生成工具 CodeSmith [转贴]

http://www.ericjsmith.net/

CodeSmith is a FREEWARE template-based code generator that allows you to generate code for any ASCII-based language. The code generated can be customized by the use of properties. A property can be any .NET object that has a designer (most built in .NET types have designers already) and can be as simple as a boolean property that allows you to conditionally add or remove code from the result, to an object such as the TableSchema object (included in SchemaExplorer) which provides access to everything you could possibly want to know about a database table.  CodeSmith is completely extensible by allowing the user to create custom property types.  Several examples of doing this are included, such as a type that allows selecting an XML file that will be deserialized into an object using the XmlSerializer.  Also, CodeSmith allows the user to specify external assemblies to be referenced and called in a template and allows for the template to be derived from a class in an external assembly.

CodeSmith's syntax is almost identical to ASP.NET. So if you are familiar with ASP.NET then you should be able to quickly learn the template syntax. You can use the C#, VB.NET or JScript.NET languages in your templates and your templates can output any ASCII-based language.

The CodeSmith Explorer window allows you to view all templates in a given folder and allows you to drag and drop to any target that supports dropping text. You can also double-click a template file in Windows Explorer to execute it.  The CodeSmith Explorer window can also be embedded into Visual Studio .NET 2003 as a tool window which allows convenient access to your templates.

CodeSmith includes a couple ways to generate code in batch.  There is a Visual Studio .NET 2003 custom tool included that allows including templates that can generate code based on multiple property sets.  This custom tool effectively allows CodeSmith to simulate generics in that you can have a template and create specialized instances of that template by adding additional property sets.  Changes made to the template will be reflected in all instances of the template as soon the custom tool is run again.  There are several highly optimized collection templates included (such as ArrayList, DictionaryList, Hashtable, IDictionary, IList, SortedList, and Stack) these templates allow creating strongly typed collections that avoid boxing and unboxing and can provide as much as a 1500% performance increase over their .NET framework counter-parts.  Also included is a console based version of CodeSmith that works identical to the Visual Studio .NET custom tool except it is run from the command line and can be included in any build process.

CodeSmith includes an assembly called SchemaExplorer that allows access to nearly all details of a database schema.  Having access to this information allows you to generate things such as stored procedures, typed DataSets, business objects, presentation layer code, or anything else you can think of based on information from a database schema.

CodeSmith is being released as freeware in an attempt to build a strong community of users and templates. I hope that this will have an end result of all us programmers doing a little less repetative boring work! In exchange, I hope to receive feedback, bug reports, tutorials, documentation and most importantly some useful templates to make my life easier!

一些网址

  1. CodeSmith Tempalate share 论坛
  2. Codesmith templates library
  3. DotNet DAL Library
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值