Export (0) Print
Expand All

How to: Import Namespaces in Text Templates 

Visual Studio 2005

You can add an import directive to text templates and use that directive to specify the namespaces that you want to use in those text templates. For more information, see Directive Syntax (Domain-Specific Languages).

You can add a namespace to a text template to avoid having to use fully qualified names in the code in your text template.

To import a namespace

  1. In Solution Explorer, right-click the text template file that you want to edit, and then click Open.

    The template opens in the editor.

  2. Specify a namespace using the import directive, as shown in the following example:

    <#@ import namespace = "System.Collections.Generic" #>
    

Example

The following example demonstrates how to use the import directive.

<#@ import namespace = "System.Collections.Generic" #>
<#
    List<string> names=new List<string>();
#>

To debug text templates, you must set the debug parameter of the template directive. For more information, see How to: Debug Text Templates.

Security

For more information, see Security of Text Templates.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft