Solution4 介面

代表整合式開發環境 (IDE) 中所有的專案和適用整個方案的屬性。 取代 SolutionSolution2Solution3

命名空間:  EnvDTE100
組件:  EnvDTE100 (在 EnvDTE100.dll 中)

語法

'宣告
<GuidAttribute("CDA7305C-78B6-4D9D-90AD-93EBE71F9341")> _
Public Interface Solution4 _
    Inherits Solution3
[GuidAttribute("CDA7305C-78B6-4D9D-90AD-93EBE71F9341")]
public interface Solution4 : Solution3
[GuidAttribute(L"CDA7305C-78B6-4D9D-90AD-93EBE71F9341")]
public interface class Solution4 : Solution3
[<GuidAttribute("CDA7305C-78B6-4D9D-90AD-93EBE71F9341")>]
type Solution4 =  
    interface
        interface Solution3
    end
public interface Solution4 extends Solution3

Solution4 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 AddIns (繼承自 Solution3)。
公用屬性 AddIns 取得 AddIns 集合,包含目前所有與方案關聯的可用增益集。
公用屬性 Count (繼承自 Solution3)。
公用屬性 Count 取得數值,指出方案中專案的數目。
公用屬性 DTE (繼承自 Solution3)。
公用屬性 DTE 取得最上層的擴充性物件。
公用屬性 Extender[String] (繼承自 Solution3)。
公用屬性 Extender[String] 取得要求的擴充項物件 (如果適用於這個物件)。
公用屬性 ExtenderCATID (繼承自 Solution3)。
公用屬性 ExtenderCATID 取得物件的擴充項分類 ID (CATID)。
公用屬性 ExtenderNames (繼承自 Solution3)。
公用屬性 ExtenderNames 取得物件的可用擴充項清單。
公用屬性 FileName (繼承自 Solution3)。
公用屬性 FileName 基礎架構。取得檔案名稱。
公用屬性 FullName (繼承自 Solution3)。
公用屬性 FullName 取得物件檔案的完整路徑和名稱。
公用屬性 Globals (繼承自 Solution3)。
公用屬性 Globals 取得 Globals 物件,此物件包含可能儲存在方案檔 (.sln)、專案檔,或使用者設定檔資料中的任何變數值。
公用屬性 IsDirty (繼承自 Solution3)。
公用屬性 IsDirty 基礎架構。決定方案是否已經變更 (已修改但未儲存)。
公用屬性 IsOpen (繼承自 Solution3)。
公用屬性 IsOpen 取得值,這個值表示方案是否開啟。
公用屬性 Parent (繼承自 Solution3)。
公用屬性 Parent 取得 Solution2 物件的直接上層父物件。
公用屬性 Projects (繼承自 Solution3)。
公用屬性 Projects 取得方案中目前專案的集合。
公用屬性 Properties (繼承自 Solution3)。
公用屬性 Properties 取得與 Solution2 物件有關的所有屬性集合。
公用屬性 Saved (繼承自 Solution3)。
公用屬性 Saved 取得或設定值,指出方案是否自從上次存檔或開啟後就未被修改過。
公用屬性 SolutionBuild (繼承自 Solution3)。
公用屬性 SolutionBuild 取得方案的 SolutionBuild 物件,它代表方案層級之組建 Automation 模型的根物件。
公用屬性 TemplatePath[String] (繼承自 Solution3)。
公用屬性 TemplatePath[String] 已由 GetProjectTemplate 取代。

回頁首

方法

  名稱 說明
公用方法 AddFromFile(String, Boolean) (繼承自 Solution3)。
公用方法 AddFromFile(String, Boolean) 根據已經儲存於系統中的專案檔,將專案加入至方案。
公用方法 AddFromTemplate(String, String, String, Boolean) (繼承自 Solution3)。
公用方法 AddFromTemplate(String, String, String, Boolean) 將現有的專案檔及其所包含的一切項目或子目錄,複製至指定的位置並加入至方案中。
公用方法 AddFromTemplateEx 將現有的專案檔及其所包含的一切項目或子目錄,複製至指定的位置並加入至方案中。
公用方法 AddSolutionFolder(String) (繼承自 Solution3)。
公用方法 AddSolutionFolder(String) 將方案資料夾加入至 ProjectItems 集合。
公用方法 Close(Boolean) (繼承自 Solution3)。
公用方法 Close(Boolean) 關閉目前的方案。
公用方法 Create(String, String) (繼承自 Solution3)。
公用方法 Create(String, String) 在指定的目錄中以指定的名稱,建立一個空白方案。
公用方法 FindProjectItem(String) (繼承自 Solution3)。
公用方法 FindProjectItem(String) 尋找專案中的一個項目。
公用方法 GetEnumerator() (繼承自 Solution3)。
公用方法 GetEnumerator() 傳回列舉集合中的項目。
公用方法 GetProjectItemTemplate(String, String) (繼承自 Solution3)。
公用方法 GetProjectItemTemplate(String, String) 傳回指定專案項目範本的路徑。
公用方法 GetProjectItemTemplates(String, String) (繼承自 Solution3)。
公用方法 GetProjectItemTemplates(String, String) 傳回指定之專案的專案項目範本集合。
公用方法 GetProjectTemplate(String, String) (繼承自 Solution3)。
公用方法 GetProjectTemplate(String, String) 傳回指定之專案範本的路徑。
公用方法 Item(Object) (繼承自 Solution3)。
公用方法 Item(Object) 傳回 Projects 集合的索引成員。
公用方法 Open(String) (繼承自 Solution3)。
公用方法 Open(String) 會開啟指定的方案。
公用方法 ProjectItemsTemplatePath(String) (繼承自 Solution3)。
公用方法 ProjectItemsTemplatePath(String) 已由 GetProjectItemTemplate 取代。
公用方法 Remove(Project) (繼承自 Solution3)。
公用方法 Remove(Project) 將指定的專案從方案中移除。
公用方法 SaveAs(String) (繼承自 Solution3)。
公用方法 SaveAs(String) 儲存方案。

回頁首

備註

Solution4 物件是 IDE 目前執行個體中所有專案,以及所有適用整個方案之屬性 (例如組建組態) 的集合。 不論專案是包裝專案、子專案或最上層專案,Solution4 物件都會包含每個專案的專案項目。

請使用 DTE.Solution 參考這個物件。 若要參考如 MiscFiles 或 SolutionItems 的虛擬專案,請使用 Solution4.Item(EnvDTE.Constants.vsProjectKindMisc) 或 Solution4.Item(EnvDTE.Constants.vsProjectKindSolutionItems)。

範例

如需如何執行增益集程式碼的詳細資訊,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例

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)
    Solution4Example(_applicationObject)
End Sub

Sub Solution4Example(ByVal dte As DTE2)
    ' This function creates a solution and adds a Visual C# Console
    ' project to it.
    Try
        Dim soln As Solution4 = CType(DTE.Solution, Solution4)
        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.
    Solution4Example((DTE2)_applicationObject);
}

public void Solution4Example(DTE2 dte)
{
    // This function creates a solution and adds a Visual C# Console
    // project to it.
    try{
        Solution4 soln = (Solution4)_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);
    }
}

請參閱

參考

EnvDTE100 命名空間