Sdílet prostřednictvím


ITextTemplatingEngineHost.ResolveAssemblyReference – metoda

Umožňuje hostiteli poskytnout další informace o umístění sestavení.

Obor názvů:  Microsoft.VisualStudio.TextTemplating
Sestavení:  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (v Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)

Syntaxe

'Deklarace
Function ResolveAssemblyReference ( _
    assemblyReference As String _
) As String
string ResolveAssemblyReference(
    string assemblyReference
)
String^ ResolveAssemblyReference(
    String^ assemblyReference
)
abstract ResolveAssemblyReference : 
        assemblyReference:string -> string 
function ResolveAssemblyReference(
    assemblyReference : String
) : String

Parametry

Vrácená hodnota

Typ: System.String
A String obsahující odkaz na určené sestavení nebo odkaz na určené sestavení dodatečné informace.

Poznámky

Pokud uživatel zadal nepovinné assembly 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 šablonu transformace textu.Další informace naleznete v tématu T4 Text šablony směrnic.

Hostitele lze vyhledat sestavení na různých místech, v pořadí upřednostňuje nebo přidat cestu k výběru na začátek odkazu na sestavení.

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 string ResolveAssemblyReference(string assemblyReference)
{
    //if the argument is the fully qualified path of an existing file,
    //then we are done (this does not do any work)
    //----------------------------------------------------------------
    if (File.Exists(assemblyReference))
    {
        return assemblyReference;
    }

    //the assembly might be in the same folder as the text template that 
    //called the directive
    //----------------------------------------------------------------
    string candidate = Path.Combine(Path.GetDirectoryName(this.inputFile), assemblyReference);
    if (File.Exists(candidate))
    {
        return candidate;
    }
        
    //this can be customized to search specific paths for the file,
    //or to search the GAC
    //----------------------------------------------------------------

    //this can be customized to accept paths to search as command line
    //arguments
    //----------------------------------------------------------------

    //if we cannot do better - return the original file name
    return "";
}
Public Function ResolveAssemblyReference(ByVal assemblyReference As String) As String Implements Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolveAssemblyReference

    'if the argument is the fully qualified path of an existing file,
    'then we are done (this does not do any work)
    '----------------------------------------------------------------
    If File.Exists(assemblyReference) Then
        Return assemblyReference
    End If


    'the assembly might be in the same folder as the text template that 
    'called the directive
    '----------------------------------------------------------------
    Dim candidate As String = Path.Combine(Path.GetDirectoryName(Me.inputFile), assemblyReference)
    If File.Exists(candidate) Then
        Return candidate
    End If

    'this can be customized to search specific paths for the file,
    'or to search the GAC
    '----------------------------------------------------------------

    'this can be customized to accept paths to search as command line
    'arguments
    '----------------------------------------------------------------

    'if we cannot do better - return the original file name
    Return ""
End Function

Zabezpečení rozhraní .NET Framework

Viz také

Referenční dokumentace

ITextTemplatingEngineHost Rozhraní

Microsoft.VisualStudio.TextTemplating – obor názvů

ResolveDirectiveProcessor

ResolvePath

Další zdroje

Názorný postup: Vytváření vlastní Text šablony hostitele