Método Events.GetObject

Obtém uma interface ou objeto que é tardia para o DTE de objeto e podem ser acessados por nome em tempo de execução.

Namespace:  EnvDTE
Assembly:  EnvDTE (em EnvDTE.dll)

Sintaxe

'Declaração
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: System.String
    Obrigatório.O nome do objeto para recuperar.

Valor de retorno

Tipo: System.Object
Um objeto.

Comentários

GetObjecté mais útil em idiomas que não oferecem suporte a vinculação antecipada. Nesse caso, você pode nomear a interface específica ou o objeto desejado, por exemplo,DTE.GetObject("VCProjects").

IExtenderSite.GetObjectsuporta apenas o valor, DTE, como o Name parâmetro. Isso é fornecido para provedores de extensor obter o DTE objeto.

Exemplos

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

Segurança do .NET Framework

Consulte também

Referência

Events Interface

Namespace EnvDTE

Outros recursos

Como: compilar e Executar a automação de exemplos de Código do modelo de objeto