Events2.GetObject(String) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Retourne une interface ou un objet disposant d'une liaison tardive à l'objet DTE et qui est accessible par son nom au moment de l'exécution.
public:
System::Object ^ GetObject(System::String ^ Name);
public:
Platform::Object ^ GetObject(Platform::String ^ Name);
winrt::Windows::Foundation::IInspectable GetObject(std::wstring const & Name);
[System.Runtime.InteropServices.DispId(314)]
public object GetObject (string Name);
[<System.Runtime.InteropServices.DispId(314)>]
abstract member GetObject : string -> obj
Public Function GetObject (Name As String) As Object
Paramètres
- Name
- String
Obligatoire. Le nom de l'objet à récupérer.
Retours
Objet.
Implémente
- Attributs
Exemples
Sub GetObjectExample(ByVal dte As DTE2)
' NOTE: This example requires a reference to the
' Microsoft.VisualStudio.VCCodeModel namespace.
Dim idents() As String = {"short", "class", "void", "var"}
Dim langMan As VCLanguageManager = _
CType(dte.GetObject("VCLanguageManager"), VCLanguageManager)
' Validate the names in idents.
Dim name, msg As String
For Each name In idents
If langMan.ValidateIdentifier(name) Then
msg &= """" & name & """ is a valid identifier." & vbCrLf
Else
msg &= """" & name & """ is not a valid identifier." & _
vbCrLf
End If
Next
MsgBox(msg)
End Sub
public void GetObjectExample(DTE2 dte)
{
// NOTE: This example requires a reference to the
// Microsoft.VisualStudio.VCCodeModel namespace.
string[] idents = {"short", "class", "void", "var"};
VCLanguageManager langMan =
(VCLanguageManager)dte.GetObject("VCLanguageManager");
// Validate the names in idents.
string msg = "";
foreach (string name in idents)
{
if (langMan.ValidateIdentifier(name))
msg += "\"" + name + "\" is a valid identifier." +
Environment.NewLine;
else
msg += "\"" + name + "\" is not a valid identifier." +
Environment.NewLine;
}
MessageBox.Show(msg);
}
Remarques
GetObject est particulièrement utile dans les langages qui ne prennent pas en charge la liaison précoce. Dans ce cas, vous pouvez nommer l’interface ou l’objet spécifique de votre choix, par exemple DTE.GetObject("VCProjects") .
IExtenderSite.GetObject prend uniquement en charge la valeur, DTE, comme Name paramètre. Cela est fourni aux fournisseurs d’extendeurs pour accéder à l' DTE objet.