Overview

CodeStencil offers an extraordinary ability: precise control over the code generation process. This functionality isn't hardwired into the CodeStencil application; rather, it is built into the stencil infrastructure, empowering you to shape it from within your stencils. This provides you with an immense creative latitude in crafting your stencils, facilitating highly tailored code generation that contrasts the behavior of conventional Visual Studio-like templates when it generates boilerplate code.

For example, the code below an ASP .NET Startup.cs class. One for SQLite, and the other for SQL Server. So, depending on your connection string (which is based on the connected database), you will have to change this. However, you can configure your stencil to generate this class in accordance with the connected database.

 

There are 2 ways you can design the code generated by your stencil to be triggered by the Database Provider in use.

  1. Triggered by Nodes - With this method, you can configure a node to generate code based on the Database Dependency setting.
  2. Triggered by Expander - With this method, you can configure a series of expanders to generate code based on the Database Dependency setting.

Was this article helpful?