CodeSmith Generator Samples

When you install CodeSmith Generator, you also get a wide variety of useful samples. These samples are of two types. Sample templates, located under the Documents\CodeSmith Generator\Samples\<VERSION>\Projects\Templates folder, can be loaded into CodeSmith Generator and used to generate code. Sample projects, located under the Documents\CodeSmith Generator\Samples\<VERSION>\Projects\Samples folder, show you how you can extend and customize CodeSmith Generator.

Generator Templates

CodeSmith Generator ships with a complete template set that helps you get up and running in no time flat. These template sets include ActiveSnippet Templates, Database Templates, Example Templates, Framework Templates and various other templates. Why waste time with repetitive tasks? Use ActiveSnippets and focus on other parts of your application.

ActiveSnippet Templates

ActiveSnippet's allow you to quickly reduce the amount of time it takes to get your job done. Any template can be used as an ActiveSnippet. CodeSmith Generator ships with active snippets that will speed up the process of creating custom events and exceptions. Also you can quickly generate an enumeration or properties from database meta data.

Database Templates

Whether you are looking for an easier ways to create a business object, document your database, script your table data, execute or create stored procedures, generator is here to save you time and headaches.

The Business Object template is a template that is a great template to use if your looking to quickly create an entity for your project. Many developers also use this template as a base template when they need to create a new POCO (Plain Old CLR Object), Data Transfer Object or Domain Class template.

The Script Table Data and Extended Properties template allows you to generate a SQL script that can be used to migrate your data between database servers or import existing data into newly created databases.

The DbDocumenter template will create a nicely formatted html document of your entire database.

The Stored Procedure template will create (Insert, Update, Delete, Select) Stored Procedures based on a Database Table. Everything is configurable to fit your unique requirements.

The Command Wrapper template will create a wrapper around any SQL Stored Procedure or SQL Function. An easy to use API allows you to execute a stored procedure or function by calling Execute() which will return get back a strongly typed object or result. When used in conjunction with the Stored Procedure templates, you can quickly get data from your database.

The Typed DataSet template creates typed DataSet and DataAdapter classes based on a database table of your choosing.

Example Templates

We provide a set of example templates that demonstrate how to use various Generator features in your own custom template.

The ASP.NET folder contains a template that will show you how to use Master Templates that will generate an ASP.NET default.aspx page. (Watch the Master Templates Video)

The Basic Samples folder contains templates that display the use of Master Templates, Partial templates and Linq To Objects in your templates.

The Maps folder is a great example on how and when to use CodeSmith Generator Maps.

The Merge folder contains templates that will show you how to use Preserve Region and Insert Region Merge Strategies across different file types and languages. (Watch the Merge Strategies Video)

The Photo Gallery folder contains templates combine using a Master Templates and code behind to create a generic photo gallery from a directory of image files.

The Xml folder contains templates that show you how to generate from an Xml data source using the XmlProperty. (Watch the XmlProperty Video)

Other Templates

The Other templates folder contains various templates that ease the use working with AJAX, Custom Collections (ArrayList, HashTable, Queues, SortedList and more) and WIX (Windows Installer Xml toolset).

Generator Sample Projects

SchemaProvider source code - All schema provider source code can be found under the CSharp folder.

BaseTemplates - This project includes the source code for the CodeSmith.BaseTemplates classes.

ConsoleSamples - This folder contains samples for use with the CodeSmith Console Application.

VSIntegrationSample - This project contains a sample of using the VS.NET integration to simulate generics with the CodeSmith Generator Project integration.

CustomPropertiesSample - This project includes the source code for the CodeSmith.CustomProperties classes.

APISample - This project demonstrates the use of the CodeSmith API.

TypedDataSetSample - This project contains a test application for the typed DataSet templates.