Proprietà _Solution.Globals

ottiene Globals che contiene i valori del componente aggiuntivo che possono essere salvati nel file di soluzione (sln), il file di progetto, o nei dati di profilo.

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

Sintassi

'Dichiarazione
ReadOnly Property Globals As Globals
Globals Globals { get; }
property Globals^ Globals {
    Globals^ get ();
}
abstract Globals : Globals
function get Globals () : Globals

Valore proprietà

Tipo: EnvDTE.Globals
In Globals oggetto.

Note

I componenti aggiuntivi è disponibile quando la soluzione, file di progetto e così via, viene caricata.

Solution i globals non sono necessariamente del componente aggiuntivo creati, possono essere create da macro o da qualsiasi altro client di automazione.

[!NOTA]

VariableValue le stringhe del nome non possono contenere uno spazio, i due punti (:), o i caratteri di punto (.).Se il nome è uno di questi caratteri, viene generato l'errore, “valore non fa parte dell'intervallo previsto.„

Esempi

Sub GlobalsExample(ByVal dte As DTE2)

    ' NOTE: This example requires a reference to the
    '       System.IO namespace.

    ' Before running this example, open a solution.

    Dim soln As Solution = dte.Solution
    Dim solnName As String = _
        Path.GetFileNameWithoutExtension(soln.FullName)

    Dim globals As String

    MsgBox("Adding global variable TempGlobal = ""TempValue""")

    soln.Globals.VariableValue("TempGlobal") = "TempValue"

    Dim names() As Object = CType(soln.Globals.VariableNames, Object())
    Dim name As String

    For Each name In names
        globals &= "    " & name & " = """ & _
            soln.Globals.VariableValue(name).ToString() & """" & vbCrLf
    Next

    MsgBox("Solution " & solnName & _
        " has the following global variables:" & _
        vbCrLf & vbCrLf & globals)

End Sub
public void GlobalsExample(DTE2 dte)
{

    // NOTE: This example requires a reference to the
    //       System.IO namespace.

    // Before running this example, open a solution.

    Solution soln = dte.Solution;
    string solnName = Path.GetFileNameWithoutExtension(soln.FullName);

    MessageBox.Show(
        "Adding global variable TempGlobal = \"TempValue\"");

    soln.Globals["TempGlobal"] = "TempValue";

    object[] names = (object[])soln.Globals.VariableNames;
    string globals = "";

    foreach (string name in names)
        globals += "    " + name + " = \"" + 
            soln.Globals[name].ToString() + "\"\n";

    MessageBox.Show("Solution " + solnName + 
        " has the following global variables:\n\n" + globals);
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

_Solution Interfaccia

Spazio dei nomi EnvDTE

Altre risorse

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