Proprietà SolutionFolder.Parent

Ottiene l'oggetto padre immediato di un oggetto Find oggetto.

Spazio dei nomi:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Sintassi

'Dichiarazione
ReadOnly Property Parent As Project
Project Parent { get; }
property Project^ Parent {
    Project^ get ();
}
abstract Parent : Project
function get Parent () : Project

Valore proprietà

Tipo: EnvDTE.Project
In DTE oggetto.

Note

Parent la proprietà restituisce il padre immediato a Find oggetto.

Esempi

In questo esempio viene creata una nuova cartella Soluzione e aggiungere un progetto da un file esistente.Quindi utilizza una finestra di messaggio per visualizzare tutti gli elementi di progetto nella cartella Soluzione, ottenuta con Parent oggetto.Prima di eseguire questo esempio, creare “i„ cartella out dall'impulso principale (“C: „ in questo esempio) e creare un oggetto Visual C# progetto Libreria di classi, denominato “ClassLibrary1„ in tale cartella.È possibile aprire un progetto in Visual Studio ambiente (IDE) di sviluppo integrato (IDE) prima di eseguire questo componente aggiuntivo.

Per ulteriori informazioni su come eseguire questo esempio viene illustrato come componente aggiuntivo, vedere Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione.

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)
    solnFolderParentExample(_applicationObject)
End Sub
Sub solnFolderParentExample(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 sb As New System.Text.StringBuilder
    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.")
        MsgBox("The name of the solution folder parent is: "  _
        & SF.Parent.Name)
        Dim tempStr As String
        tempStr = ""
        For Each temp As ProjectItem In SF.Parent.ProjectItems
            tempStr = tempStr & temp.Name & vbCr
        Next
        MsgBox("The names of the project items in the solution _
        folder SF are:" & vbCr & tempStr)
    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;
    solnFolderParentExample(_applicationObject);
}
public void solnFolderParentExample(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.");
        MessageBox.Show("The name of the solution folder parent is: " 
+ SF.Parent.Name);
        String tempStr = null;
        foreach(ProjectItem temp in SF.Parent.ProjectItems)
        {
            tempStr = tempStr + temp.Name + "\n";
        }
        MessageBox.Show("The names of the project items in the 
solution folder SF are:" + "\n" + tempStr);
    }
    catch(SystemException ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

SolutionFolder Interfaccia

Spazio dei nomi EnvDTE80