If you want to customize the functionality of your text templates, you can write your own custom directive processors. To create a custom directive processor, create a class that inherits from either DirectiveProcessor or RequiresProvidesDirectiveProcessor. For more information, see Creating Custom Text Template Directive Processors.
Before you call a custom directive processor from a text template in Visual Studio, you must enter the directive in the registry. The location for directive processors in the registry is:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\TextTemplating\DirectiveProcessors
警告
Incorrectly editing the registry can severely damage your system. Before making changes to the registry, be sure to back up any valued data on the computer.
This procedure is necessary only if you want to transform your text template in Visual Studio. If you call a custom directive processor from a template, and use the command line tool to transform the template, you do not need to enter the processor in the registry. For more information, see Command-Line Tools for Text Templates.
To enter a directive processor in the registry
On the Start menu, click Run.
In the Run dialog, type regedit, and then click OK.
The Registry Editor appears.
Browse to the location HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\TextTemplating\DirectiveProcessors, and select the node.
On the Edit menu, click New, and then click Key.
Type the name of your directive processor as the name of the new key.
注意
You can choose anything you want for the name of the directive processor registry key. The name of the directive processor registry key does not have to be the same as the name of the directive, the directive processor class, or the directive processor namespace.
Right-click the new key, click New, and then click String Value.
Type Class for the name of the new string.
Right-click Class and click Modify.
In the Edit String dialog, for Value data, type the namespace and the class name of your custom directive processor.
For example, type CustomDP.CustomDirectiveProcessor.
Right-click the new key again, click New, and then click String Value.
Type CodeBase for the name of the new string.
注意
If you install your directive processor dll in the Global Assembly Cache, you can add an Assembly entry instead of a CodeBase entry. For more information, see the next procedure.
Right-click CodeBase and click Modify.
In the Edit String dialog, for Value data, type the address of the dll containing your custom directive processor class.
For example, type C:\UserFiles\CustomDP\bin\Debug\CustomDP.dll.
When you are done, your new registry key should have the following values:
Name
Type
Data
(Default)
REG_SZ
(value not set)
Class
REG_SZ
<Namespace Name>.<Class Name>
CodeBase
REG_SZ
<Your Path>\<Your dll Name>
To enter a directive processor in the GAC in the registry
Follow the same steps as above. In step 11, instead of a CodeBase entry, add an Assembly entry.
When you are done, your new registry key should have the following values:
Name
Type
Data
(Default)
REG_SZ
(value not set)
Assembly
REG_SZ
<Your Assembly Name in the GAC>
Class
REG_SZ
<Your Fully Qualified Class Name>
See Also
Concepts
Architecture of the Text Template Transformation Process
Walkthrough: Creating a Custom Directive Processor