How to: Set Registry Keys for Custom Directive Processors

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

  1. On the Start menu, click Run.

  2. In the Run dialog, type regedit, and then click OK.

    The Registry Editor appears.

  3. Browse to the location HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\TextTemplating\DirectiveProcessors, and select the node.

  4. On the Edit menu, click New, and then click Key.

  5. 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.

  6. Right-click the new key, click New, and then click String Value.

  7. Type Class for the name of the new string.

  8. Right-click Class and click Modify.

  9. 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.

  10. Right-click the new key again, click New, and then click String Value.

  11. 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.

  12. Right-click CodeBase and click Modify.

  13. 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

Reference

DirectiveProcessor

RequiresProvidesDirectiveProcessor