|
The T4 engine that ships with the DSL tools gives you a flexible way to generate text output based on the contents of a model by running a custom tool against a template. However, in a production environment, you may not want a user of your designer to have access to the template. You might prefer the user experience to be more like that provided by the Microsoft dataset generator, where the custom tool runs directly against the model file, rather than against a template. This is very easy to do using the May release of the DSL tools. 1) Create and test your template as normal, but then put in a placeholder in the directive where the name of the model would usually go e.g. ??MODELFILENAME%?? 2) Create a new class that inherits from TemplatedCodeGenerator. You can make life easier for yourself by including the following import statements: using Microsoft.VisualStudio.TextTemplating.VSHost; using System.Runtime.InteropServices; using Microsoft.VisualStudio.EnterpriseTools.Shell; using System.IO; 3) Add a new Guid custom attribute to the class e.g. |