Metoda ITextTemplatingEngineHost.ResolveAssemblyReference —
Umożliwia hosta podać dodatkowe informacje o lokalizacji asemblowania.
Przestrzeń nazw: Microsoft.VisualStudio.TextTemplating
Zestaw: Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (w Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)
Składnia
'Deklaracja
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
Zgromadzenie rozwiązać.
Wartość zwracana
Typ: System.String
A String zawierający odwołanie do określonego zestawu lub odwołania do określonego zestawu z dodatkowymi informacjami.
Uwagi
Jeśli użytkownik określił opcjonalna assembly dyrektywy w szablonie tekst silnika wywołuje tę metodę.0, 1 Lub wiele razy dla każdego tekstu szablonu transformacji można wywołać tej metody.Aby uzyskać więcej informacji, zobacz T4 Tekst szablonu dyrektyw.
Host można znaleźć zestawu w różnych miejscach, w celu preferuje lub dodać ścieżkę wybór rozpoczęcie odwołanie do zestawu.
Przykłady
Poniższy przykład kodu pokazuje możliwe wdrożenie niestandardowych hosta.Poniższy przykład kodu jest częścią większej przykład.Na przykład pełną, zobacz Instruktaż: Tworzenie hosta szablon niestandardowy tekst.
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
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Przy użyciu bibliotek z częściowo zaufanego kodu..
Zobacz też
Informacje
ITextTemplatingEngineHost Interfejs
Przestrzeń nazw Microsoft.VisualStudio.TextTemplating