Solution3 接口
表示集成开发环境 (IDE) 中所有的项目和解决方案属性。 取代 Solution 和 Solution2。
命名空间: EnvDTE90
程序集: EnvDTE90(在 EnvDTE90.dll 中)
语法
声明
<GuidAttribute("DF23915F-FDA3-4DD5-9CAA-2E1372C2BB16")> _
Public Interface Solution3 _
Inherits Solution2
[GuidAttribute("DF23915F-FDA3-4DD5-9CAA-2E1372C2BB16")]
public interface Solution3 : Solution2
[GuidAttribute(L"DF23915F-FDA3-4DD5-9CAA-2E1372C2BB16")]
public interface class Solution3 : Solution2
[<GuidAttribute("DF23915F-FDA3-4DD5-9CAA-2E1372C2BB16")>]
type Solution3 =
interface
interface Solution2
end
public interface Solution3 extends Solution2
Solution3 类型公开以下成员。
属性
名称 | 说明 | |
---|---|---|
![]() |
AddIns | (继承自 Solution2。) |
![]() |
AddIns | 获取 AddIns 集合,它包含与解决方案关联的所有当前可用的外接程序。 |
![]() |
Count | (继承自 Solution2。) |
![]() |
Count | 获取一个值,该值指示解决方案中项目的数目。 |
![]() |
DTE | (继承自 Solution2。) |
![]() |
DTE | 获取顶级扩展性对象。 |
![]() |
Extender[String] | (继承自 Solution2。) |
![]() |
Extender[String] | 如果请求的扩展程序对象可用于此对象,则获取该扩展程序对象。 |
![]() |
ExtenderCATID | (继承自 Solution2。) |
![]() |
ExtenderCATID | 获取对象的扩展程序类别 ID (CATID)。 |
![]() |
ExtenderNames | (继承自 Solution2。) |
![]() |
ExtenderNames | 获取对象的可用扩展程序的列表。 |
![]() |
FileName | (继承自 Solution2。) |
![]() |
FileName | 基础结构。获取文件名。 |
![]() |
FullName | (继承自 Solution2。) |
![]() |
FullName | 获取对象文件的完整路径和名称。 |
![]() |
Globals | (继承自 Solution2。) |
![]() |
Globals | 获取 Globals 对象,该对象包含可以保存在解决方案 (.sln) 文件、项目文件或用户的配置文件数据中的任何变量值。 |
![]() |
IsDirty | (继承自 Solution2。) |
![]() |
IsDirty | 基础结构。确定解决方案是否已更新(已修改但未保存)。 |
![]() |
IsOpen | (继承自 Solution2。) |
![]() |
IsOpen | 获取一个表示解决方案是否打开的值。 |
![]() |
Parent | (继承自 Solution2。) |
![]() |
Parent | 获取 Solution2 对象的直接父对象。 |
![]() |
Projects | (继承自 Solution2。) |
![]() |
Projects | 获取解决方案中当前项目的集合。 |
![]() |
Properties | (继承自 Solution2。) |
![]() |
Properties | 获取属于 Solution2 对象的所有属性的集合。 |
![]() |
Saved | (继承自 Solution2。) |
![]() |
Saved | 获取或设置一个值,该值指示解决方案自上次保存或打开以来是否未经过修改。 |
![]() |
SolutionBuild | (继承自 Solution2。) |
![]() |
SolutionBuild | 获取解决方案的 SolutionBuild 对象,该对象表示位于解决方案级的生成自动化模型的根。 |
![]() |
TemplatePath[String] | (继承自 Solution2。) |
![]() |
TemplatePath[String] | 已被 GetProjectTemplate 取代。 |
页首
方法
页首
备注
Solution3 对象是 IDE 当前实例中所有的项目和所有解决方案属性(如生成配置)的集合。 Solution3 对象对于每个项目都包含一个对应的项目元素,不管该项目是打包项目、子项目,还是顶级项目。
使用 DTE.Solution 引用此对象。 若要引用虚项目(如 MiscFile 或 SolutionItem),请使用 Solution3.Item(EnvDTE.Constants.vsProjectKindMisc) 或 Solution3.Item(EnvDTE.Constants.vsProjectKindSolutionItems)。
示例
有关如何运行此外接程序代码的信息,请参见如何:编译和运行自动化对象模型代码示例。
Public Sub OnConnection(ByVal application As Object, _
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
Solution3Example(_applicationObject)
End Sub
Sub Solution3Example(ByVal dte As DTE2)
' This function creates a solution and adds a Visual C# Console
' project to it.
Try
Dim soln As Solution3 = CType(DTE.Solution, Solution3)
Dim csTemplatePath As String
' This path must exist on your computer.
' Replace <file path> below with an actual path.
Dim csPrjPath As String = "<file path>"
MsgBox("starting")
' Get the project template path for a C# console project.
csTemplatePath = CType(soln.GetProjectTemplate _
("ConsoleApplication.zip", "CSharp"), string)
' Create a new C# Console project using the template obtained
' above.
soln.AddFromTemplate(csTemplatePath, csPrjPath, _
"New CSharp Console Project", False)
MsgBox("done")
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
using System.Windows.Forms;
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst,
ref System.Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
// Pass the applicationObject member variable to the code example.
Solution3Example((DTE2)_applicationObject);
}
public void Solution3Example(DTE2 dte)
{
// This function creates a solution and adds a Visual C# Console
// project to it.
try{
Solution3 soln = (Solution3)_applicationObject.Solution;
String csTemplatePath;
// The file path must exist on your computer.
// Replace <file path> below with an actual path.
String csPrjPath = "<file path>";
"<file path>MessageBox.Show("Starting...");
"<file path>"<file path>csTemplatePath =
soln.GetProjectTemplate("ConsoleApplication.zip", "CSharp");
// Create a new C# Console project using the template obtained
// above.
soln.AddFromTemplate(csTemplatePath, csPrjPath,
"New CSharp Console Project", false);
MessageBox.Show("Done!");
}
catch(SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}