Compartir a través de


_DTE.GetObject (Método)

Obtiene una interfaz o un objeto enlazados en tiempo de ejecución al objeto DTE y a los que se puede tener acceso en tiempo de ejecución por su nombre.

Espacio de nombres:  EnvDTE
Ensamblado:  EnvDTE (en EnvDTE.dll)

Sintaxis

'Declaración
Function GetObject ( _
    Name As String _
) As Object
Object GetObject(
    string Name
)
Object^ GetObject(
    [InAttribute] String^ Name
)
abstract GetObject : 
        Name:string -> Object
function GetObject(
    Name : String
) : Object

Parámetros

  • Name
    Tipo: String

    Requerido. Nombre del objeto que se va a recuperar.

Valor devuelto

Tipo: Object
Interfaz u objeto enlazado en tiempo de ejecución al objeto DTE.

Comentarios

El método GetObject es especialmente útil en lenguajes que no admiten enlaces en tiempo de compilación. En este caso, se puede dar nombre al objeto o interfaz específicos que se desee como, por ejemplo, DTE.GetObject("VCProjects").

IExtenderSite.GetObject sólo admite el valor "DTE" como parámetro Name. Se proporciona para permitir que los proveedores extensores puedan llegar al objeto DTE.

Ejemplos

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);
}

Seguridad de .NET Framework

Vea también

Referencia

_DTE Interfaz

EnvDTE (Espacio de nombres)

Otros recursos

Cómo: Compilar y ejecutar los ejemplos de código del modelo de objetos de automatización