SolutionFolder, interface

Mise à jour : novembre 2007

Les dossiers de solution sont des conteneurs de projets qui permettent aux développeurs de mieux organiser les grandes applications.

Espace de noms :  EnvDTE80
Assembly :  EnvDTE80 (dans EnvDTE80.dll)

Syntaxe

<GuidAttribute("F8F69788-267C-4408-8967-74F26108C438")> _
Public Interface SolutionFolder

Dim instance As SolutionFolder
[GuidAttribute("F8F69788-267C-4408-8967-74F26108C438")]
public interface SolutionFolder
[GuidAttribute(L"F8F69788-267C-4408-8967-74F26108C438")]
public interface class SolutionFolder
public interface SolutionFolder

Notes

Dans Visual Studio 2005, les solutions peuvent contenir des dossiers de solution en plus des dossiers de projet. Les dossiers de solution sont des conteneurs de projets qui permettent aux développeurs de mieux organiser les grandes applications.

La propriété Projects de la solution retourne une collection d'objets Project. Chaque projet individuel a une propriété Kind qui peut être définie à vsProjectKindSolutionFolder. Pour accéder à l'interface SolutionFolder, appelez Project.Object, puis effectuez un cast de l'objet retourné en un type SolutionFolder.

Exemples

Cet exemple crée un nouveau dossier de solution et y ajoute un projet à partir d'un fichier existant. Avant d'exécuter cet exemple, créez un dossier "Projects" sur votre lecteur principal ("C:" dans cet exemple) et créez dans ce dossier un projet Bibliothèque de classes Visual C#, nommé "ClassLibrary1". Vous devez également ouvrir un projet dans l'IDE de Visual Studio avant d'exécuter ce complément.

Pour plus d'informations sur l'exécution de cet exemple comme complément, consultez Comment : compiler et exécuter les exemples de code du modèle objet Automation.

Imports EnvDTE
Imports EnvDTE80
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)
    solnFolderAddFromFileExample(_applicationObject)
End Sub
Sub solnFolderAddFromFileExample(ByVal dte As DTE2)
    ' Before running this example, create a "Projects" folder
    ' off your main drive (C: in this example), and create a C# 
    ' class library project, named ClassLibrary1 in that folder.
    Dim soln As Solution2 = CType(_applicationObject.Solution _
    , Solution2)
    Dim prj As Project
    Dim SF As SolutionFolder
    Try
        Dim prjPath As String = _
        "C:\Projects\ClassLibrary1\ClassLibrary1\ClassLibrary1.csproj"
        ' Open a project in the Visual Studio IDE before running 
        ' this add-in.
        ' Add a solution folder.
        prj = soln.AddSolutionFolder("A new soln folder")
        SF = CType(prj.Object, SolutionFolder)
        ' Add a project to the new solution folder.
        SF.AddFromFile(prjPath)
        MsgBox("Added a new solution folder that contains a _
        C# project named ClassLibrary1.")
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    solnFolderAddFromFileExample(_applicationObject);
}
public void solnFolderAddFromFileExample(DTE2 dte)
{
    // Before running this example, create a "Projects" folder
    // off your main drive (C: in this example), and create a C# 
    // class library project, named ClassLibrary1 in that folder.
    Solution2 soln = (Solution2)_applicationObject.Solution;
    Project prj;
    SolutionFolder SF;
    try
    {
        String prjPath =
 "C:\\Projects\\ClassLibrary1\\ClassLibrary1\\ClassLibrary1.csproj";
        // Open a project in the Visual Studio IDE before running 
        // this add-in.
        // Add a solution folder.
        prj = soln.AddSolutionFolder("A new soln folder");
        SF = (SolutionFolder)prj.Object;
        // Add a project to the new solution folder.
        SF.AddFromFile(prjPath);
    MessageBox.Show("Added a new solution folder that contains a 
C# project named ClassLibrary1.");
    }
    catch(SystemException ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

Voir aussi

Référence

Membres SolutionFolder

EnvDTE80, espace de noms