Metodo Events.GetObject

Ottiene un'interfaccia o dell'oggetto che è associato tardivamente a DTE l'oggetto e possono accedere per nome in fase di esecuzione.

Spazio dei nomi:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Sintassi

'Dichiarazione
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

Parametri

  • Name
    Tipo: System.String
    obbligatorio.Il nome dell'oggetto da recuperare.

Valore restituito

Tipo: System.Object
un oggetto.

Note

GetObject è particolarmente utile in linguaggi che non supportano l'associazione anticipata.In questo caso, è possibile denominare l'interfaccia specifica l'oggetto o esempio, ad esempio, DTE.GetObject("VCProjects").

IExtenderSite.GetObject supporta solo il valore, DTE, ad esempio Name parametro.Viene fornita per i provider di estensione ottenga a DTE oggetto.

Esempi

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Events Interfaccia

Spazio dei nomi EnvDTE

Altre risorse

Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione