Solution3 接口

表示集成开发环境 (IDE) 中所有的项目和解决方案属性。 取代 SolutionSolution2

命名空间:  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] 如果请求的 Extender 对象可用于此对象,则获取该 Extender 对象。
公共属性 ExtenderCATID (继承自 Solution2。)
公共属性 ExtenderCATID 获取对象的扩展程序类别 ID (CATID)。
公共属性 ExtenderNames (继承自 Solution2。)
公共属性 ExtenderNames 获取此对象的可用 Extender 的列表。
公共属性 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 取代。

页首

方法

  名称 说明
公共方法 AddFromFile(String, Boolean) (继承自 Solution2。)
公共方法 AddFromFile(String, Boolean) 向基于已存储在系统中的项目文件的解决方案添加一个项目。
公共方法 AddFromTemplate(String, String, String, Boolean) (继承自 Solution2。)
公共方法 AddFromTemplate(String, String, String, Boolean) 将现有项目文件及其包含的任何项或子目录复制到指定位置,并将其添加到解决方案。
公共方法 AddSolutionFolder(String) (继承自 Solution2。)
公共方法 AddSolutionFolder(String) 将解决方案文件夹添加到 ProjectItems 集合中。
公共方法 Close(Boolean) (继承自 Solution2。)
公共方法 Close(Boolean) 关闭当前解决方案。
公共方法 Create(String, String) (继承自 Solution2。)
公共方法 Create(String, String) 在指定的目录中创建具有指定名称的空解决方案。
公共方法 FindProjectItem(String) (继承自 Solution2。)
公共方法 FindProjectItem(String) 在项目中定位项。
公共方法 GetEnumerator() (继承自 Solution2。)
公共方法 GetEnumerator() 返回集合中项的枚举。
公共方法 GetProjectItemTemplate(String, String) (继承自 Solution2。)
公共方法 GetProjectItemTemplate(String, String) 返回所指示的项目项模板的路径。
公共方法 GetProjectItemTemplates 返回指定项目的项目项模板的集合。
公共方法 GetProjectTemplate(String, String) (继承自 Solution2。)
公共方法 GetProjectTemplate(String, String) 返回指定项目模板的路径。
公共方法 Item(Object) (继承自 Solution2。)
公共方法 Item(Object) 返回 Projects 集合的一个索引成员。
公共方法 Open(String) (继承自 Solution2。)
公共方法 Open(String) 打开指定的解决方案。
公共方法 ProjectItemsTemplatePath(String) (继承自 Solution2。)
公共方法 ProjectItemsTemplatePath(String) 已被 GetProjectItemTemplate 取代。
公共方法 Remove(Project) (继承自 Solution2。)
公共方法 Remove(Project) 从解决方案中移除指定的项目。
公共方法 SaveAs(String) (继承自 Solution2。)
公共方法 SaveAs(String) 保存解决方案。

页首

备注

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

请参见

参考

EnvDTE90 命名空间