Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

ITextTemplatingEngineHost.LoadIncludeText Method

Acquires the text that corresponds to a request to include a partial text template file.

Namespace: Microsoft.VisualStudio.TextTemplating
Assembly: Microsoft.VisualStudio.TextTemplating (in microsoft.visualstudio.texttemplating.dll)

bool LoadIncludeText (
	string requestFileName,
	out string content,
	out string location
)
boolean LoadIncludeText (
	String requestFileName, 
	/** @attribute OutAttribute() */ /** @ref */ String content, 
	/** @attribute OutAttribute() */ /** @ref */ String location
)
JScript does not support passing value-type arguments by reference.

Parameters

requestFileName

The name of the partial text template file to acquire.

content

A String that contains the acquired text, or Empty if the file could not be found.

location

A String that contains the location of the acquired text. If the host searches the registry for the location of include files, or if the host searches multiple locations by default, the host can return the final path of the include file in this parameter. The host can set location to Empty if the file could not be found, or if the host is not file system based.

Return Value

true to indicate that the host was able to acquire the text successfully; otherwise, false.

If the user has specified the optional include directive in a text template, the engine calls this method. This method can be called 0, 1, or multiple times for each text template transformation. For more information, see Directive Syntax (Domain-Specific Languages).

This method can also be called from a custom directive processor.

The following code example shows a possible implementation for a custom host. This code example is part of a larger example provided for the ITextTemplatingEngineHost interface.

public bool LoadIncludeText(string requestFileName, out string content, out string location)
{
    content = System.String.Empty;
    location = System.String.Empty;
    
    //If the argument is the fully qualified path of an existing file,
    //then we are done.
    //----------------------------------------------------------------
    if (File.Exists(requestFileName))
    {
        content = File.ReadAllText(requestFileName);
        return true;
    }

    //This can be customized to search specific paths for the file.
    //This can be customized to accept paths to search as command line
    //arguments.
    //----------------------------------------------------------------
    else
    {
        return false;
    }
}

Community Additions

ADD
Show:
© 2015 Microsoft