获取文本,它对应于包含部分文本模板文件的请求。
命名空间:  Microsoft.VisualStudio.TextTemplating
程序集:  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0(在 Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll 中)
语法
声明
Function LoadIncludeText ( _
    requestFileName As String, _
    <OutAttribute> ByRef content As String, _
    <OutAttribute> ByRef location As String _
) As Boolean
bool LoadIncludeText(
    string requestFileName,
    out string content,
    out string location
)
bool LoadIncludeText(
    String^ requestFileName, 
    [OutAttribute] String^% content, 
    [OutAttribute] String^% location
)
abstract LoadIncludeText : 
        requestFileName:string * 
        content:string byref * 
        location:string byref -> bool 
function LoadIncludeText(
    requestFileName : String, 
    content : String, 
    location : String
) : boolean
参数
- requestFileName
 类型:System.String
 要获取的部分文本模板文件的名称。
- content
 类型:System.String%
 一个 String,其中包含所获取的文本;如果未能找到文件,则为 Empty。
- location
 类型:System.String%
 一个 String,其中包含所获取文本的位置。如果主机在注册表中搜索包含文件的位置,或者主机默认搜索多个位置,则主机可能在此参数中返回包含文件的最终路径。如果未能找到文件或者主机不是基于文件系统,则主机可以将 location 设置为 Empty。
返回值
类型:System.Boolean
如果为 true,则指示主机可以获取文本;否则为 false。
备注
如果用户在文本模板中指定可选的 include 指令,该引擎将调用此方法。 对于每次转换,可以调用此方法 0 次、1 次或多次。 有关更多信息,请参见 T4 文本模板指令。
也可以从自定义指令处理器调用此方法。
示例
下面的代码示例演示了自定义主机的可能实现。 此代码示例摘自一个更大的示例。 有关完整的示例,请参见演练:创建自定义文本模板宿主。
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;
    }
}
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
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualStudio.TextTemplating 命名空间