OutputFileCodeTemplate
To base a template on the OutputFileCodeTemplate class, you inherit from this class in your template's CodeTemplate directive:
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Inherits="OutputFileCodeTemplate" Description="Build custom access code." %> <%@ Assembly Name="CodeSmith.BaseTemplates" %>
The OutputFileCodeTemplate class does two things. First, it adds a property named OutputFile to your template. This property requires you to select a filename. Second, the template overrides the OnPostRender method to write the output of your template to the specified file after CodeSmith has finished generating code.
If you want to customize the Save File dialog box used by the OutputFile property, you can override the OutputFile property in your own template. For example, if you want to force the user to select a .cs file for output, you'd include this code in your template:
<script runat="template"> // Override the OutputFile property and assign our specific settings to it. [FileDialog(FileDialogType.Save, Title="Select Output File", Filter="C# Files (.cs)|.cs", DefaultExtension=".cs")] public override string OutputFile { get {return base.OutputFile;} set {base.OutputFile = value;} } </script>