Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Studio SDK
 LoadIncludeText Method
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Domain-Specific Language Tools Reference
ITextTemplatingEngineHost..::.LoadIncludeText Method

Updated: November 2007

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)

Visual Basic (Declaration)
Function LoadIncludeText ( _
    requestFileName As String, _
    <OutAttribute> ByRef content As String, _
    <OutAttribute> ByRef location As String _
) As Boolean
Visual Basic (Usage)
Dim instance As ITextTemplatingEngineHost
Dim requestFileName As String
Dim content As String
Dim location As String
Dim returnValue As Boolean

returnValue = instance.LoadIncludeText(requestFileName, _
    content, location)
C#
bool LoadIncludeText(
    string requestFileName,
    out string content,
    out string location
)
Visual C++
bool LoadIncludeText(
    String^ requestFileName, 
    [OutAttribute] String^% content, 
    [OutAttribute] String^% location
)
JScript
function LoadIncludeText(
    requestFileName : String, 
    content : String, 
    location : String
) : boolean

Parameters

requestFileName
Type: System..::.String

The name of the partial text template file to acquire.

content
Type: System..::.String%

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

location
Type: System..::.String%

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 the location to Empty if the file could not be found or if the host is not file-system based.

Return Value

Type: System..::.Boolean

true to indicate that the host was able to acquire the text; 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 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 that is provided for the ITextTemplatingEngineHost interface.

C#
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;
    }
}
Visual Basic
Public Function LoadIncludeText(ByVal requestFileName As String, ByRef content As String, ByRef location As String) As Boolean Implements ITextTemplatingEngineHost.LoadIncludeText

    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) Then

        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
    End If
End Function
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker