The T4Utilities are a series of T4 Directives and other utilities that help and extend the usage of the T4 Template Engine supplied with Visual Studio 2010. Define Directive The Define Directive allows you to create key/value pairs for text substitution in T4Utility directive properties. Additionally it allows you to inject simple C# properties into your templates. LoadAssembly Directive The LoadAssembly Directve works like the T4 Assembly Directive with several enhancements:
IncludeFile Directive The IncludeFile Directive allows you to inject code into the template file for compilation, or set a C# property which will return the contents of the file when it is referenced. In addition the directive can also create a property referencing an XElement, XmlDocument, or an INI file which are read and created when the property is referenced from your C# template code. Namespaces Directive The Namespaces Directive allows you to specify more than one namespace at a time. GetSource Directive The GetSource Directive allows you to save the generated source to a convenient location for inspection. GetService Directive (Experimental) The GetService Directive allows you to create objects using LinFu IOC containers. The interfaces, abstract classes or concrete classes you wish to create are named (e.g. "IMyInterface"), not referenced by type (e.g. typeof(IMyInterface)) so your template does not have to reference the assemblies that contain the types you want to use. The GetService Directive locates the types you wish to use, adds references to the appropriate assemblies and imports the required namespaces for compilation. Helpers Directive The Helpers directive introduces a number of helper methods that are used by the code generated by several of the directives. These and other methods can used by the users template code. Some of these methods allow you to save the contents of the template output buffer to a file, stash the contents for later use, clear the buffer for use in a code generating loop, etc.. A Help File, Examples Project and other Downloads are available here
|