Compartir a través de


_Solution.Globals (Propiedad)

Obtiene el objeto Globals que contiene valores de complementos que pueden guardarse en el archivo de solución (.sln), en el archivo de proyecto o en los datos de perfil de usuario.

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

Sintaxis

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

Valor de propiedad

Tipo: EnvDTE.Globals
Un objeto Globals.

Comentarios

Los complementos están disponibles cuando se carga la solución, el archivo de proyecto, etc.

Las variables globales Solution no las crea necesariamente un complemento; también las pueden crear macros o cualquier otro cliente de automatización.

[!NOTA]

Las cadenas de nombre de VariableValue no pueden contener los caracteres de espacio, dos puntos (:) ni punto (.).Si un nombre tiene cualquiera de estos caracteres, obtendrá el error "El valor no está dentro del intervalo esperado".

Ejemplos

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

Seguridad de .NET Framework

Vea también

Referencia

_Solution Interfaz

EnvDTE (Espacio de nombres)

Otros recursos

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