Sdílet prostřednictvím


ITextTemplatingEngineHost.LoadIncludeText – metoda

Získá text, který odpovídá na požadavek na 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.
  • location
    Typ: System.String%
    A String , který obsahuje umístění získaných text.Pokud hostitel prohledá registru pro umístění souborů include nebo pokud hostitel prohledá standardně více umístění, hostitel vrátit koncová cesta zahrnuje soubor v tomto parametru.Hostitele lze nastavit location na Empty Pokud soubor nebyl nalezen nebo není hostitelský systém souborů založený.

Vrácená hodnota

Typ: System.Boolean
true Označte, že hostitel byl schopen získat text; jinak false.

Poznámky

Pokud uživatel zadal nepovinný include směrnice v šabloně text motoru volá metodu. Tuto metodu lze volat 0, 1 nebo více než jednou pro každou transformaci. Další informace naleznete v tématu Text šablona 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 Walkthrough: Vytváření Uživatelský text šablona hostitel.

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

Viz také

Odkaz

ITextTemplatingEngineHost Rozhraní

Microsoft.VisualStudio.TextTemplating – obor názvů

Další zdroje

Walkthrough: Vytváření Uživatelský text šablona hostitel