Solution4.Globals 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 Globals 对象,该对象包含可以保存在解决方案 (.sln) 文件、项目文件或用户的配置文件数据中的任何变量值。
public:
property EnvDTE::Globals ^ Globals { EnvDTE::Globals ^ get(); };
public:
property EnvDTE::Globals ^ Globals { EnvDTE::Globals ^ get(); };
[System.Runtime.InteropServices.DispId(31)]
public EnvDTE.Globals Globals { [System.Runtime.InteropServices.DispId(31)] get; }
[<System.Runtime.InteropServices.DispId(31)>]
[<get: System.Runtime.InteropServices.DispId(31)>]
member this.Globals : EnvDTE.Globals
Public ReadOnly Property Globals As Globals
属性值
Globals 对象。
实现
- 属性
示例
Sub GlobalsExample(ByVal dte As DTE2)
' Add a global variable to a solution and display it.
' Open a solution in Visual Studio before running this example.
Try
Dim soln As Solution4 = _
CType(_applicationObject.Solution, Solution4)
Dim solnName As String = _
System.IO.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)
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
using System.Windows.Forms;
public void GlobalsExample(DTE2 dte)
{
// Add a global variable to the solution and displays it.
// Open a solution in Visual Studio before running this example.
try
{
Solution4 soln = (Solution4)_applicationObject.Solution;
string solnName =
System.IO.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);
}
catch(SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
注解
Globals 可能与任何自动化客户端关联。