ITextTemplatingEngineHost.ResolveAssemblyReference – metoda
Umožňuje poskytnout další informace o umístění sestavení hostitele.
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
- assemblyReference
Typ: System.String
Sestavení řešení.
Vrácená hodnota
Typ: System.String
A String , který obsahuje odkaz na určené sestavení nebo odkaz na určené sestavení s další informace.
Poznámky
Pokud uživatel zadal nepovinný assembly směrnice v šabloně text motoru volá metodu. Tuto metodu lze volat 0, 1 nebo více než jednou pro každou šablonu transformace textu. Další informace naleznete v tématu Text šablona směrnic.
Hostitele lze hledat sestavení na různých místech v pořadí upřednostňuje nebo přidat cestu 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 Walkthrough: Vytváření Uživatelský text šablona hostitel.
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
- 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é
Odkaz
ITextTemplatingEngineHost Rozhraní
Microsoft.VisualStudio.TextTemplating – obor názvů