ITextTemplatingEngineHost.LoadIncludeText – metoda
Získá text, který odpovídá na požadavek zahrnout soubor šablony část textu.
Obor názvů: Microsoft.VisualStudio.TextTemplating
Sestavení: Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (v Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)
Syntaxe
'Deklarace
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
Parametry
- requestFileName
Typ: System.String
Název souboru šablony část textu získat.
- content
Typ: System.String%
A String , který obsahuje text získaných nebo Empty v případě, že soubor nebyl nalezen.
- location
Typ: System.String%
A String , který obsahuje umístění získaných text.Pokud hostitel vyhledá umístění zahrnout soubory nebo pokud hostitele vyhledá více umístění ve výchozím nastavení v registru, hostitel vrátit koncová cesta zahrnuje soubor v tomto parametru.Hostitele lze nastavit location na Empty Pokud soubor nebyl nalezen nebo hostitel není založen systém souborů.
Vrácená hodnota
Typ: System.Boolean
true označuje, že hostitel byl schopen získat text; jinak false.
Poznámky
Pokud uživatel zadal nepovinné include směrnice v šabloně text, motor volání této metody.Tuto metodu lze volat 0, 1 nebo více než jednou pro každou transformaci.Další informace naleznete v tématu T4 Text šablony směrnic.
Tuto metodu lze volat také z vlastní procesor směrnice.
Příklady
Následující příklad kódu ukazuje možné provedení vlastního hostitele.Příklad kódu je součástí větší příklad.Pro plný příklad, viz Názorný postup: Vytváření vlastní Text šablony hostitele.
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
Zabezpečení rozhraní .NET Framework
- Plná důvěra přímému volajícímu. Částečně zabezpečený kód nemůže tento člen použít. Další informace naleznete v tématu Používání knihoven z částečně důvěryhodného kódu.
Viz také
Referenční dokumentace
ITextTemplatingEngineHost Rozhraní
Microsoft.VisualStudio.TextTemplating – obor názvů