Udostępnij za pośrednictwem


Właściwość SolutionFolder.DTE —

Pobiera obiekt rozszerzalności najwyższego poziomu.

Przestrzeń nazw:  EnvDTE80
Zestaw:  EnvDTE80 (w EnvDTE80.dll)

Składnia

'Deklaracja
ReadOnly Property DTE As DTE
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
abstract DTE : DTE
function get DTE () : DTE

Wartość właściwości

Typ: EnvDTE.DTE
A DTE object.

Uwagi

W programie Visual Studio DTE obiekt jest katalogu głównego modelu automatyzacji, który innych modeli obiektów często call "Aplikacja".

Przykłady

W tym przykładzie tworzy nowy folder rozwiązania i dodaje do niej projektu, z istniejącego pliku.Następnie wykorzystuje okno komunikatu Aby wyświetlić podpis głównego okna, uzyskane poprzez DTE obiektu.Przed uruchomieniem w tym przykładzie należy utworzyć folder "Projekty" wyłączanie dysku głównego ("C:" w tym przykładzie), a następnie utwórz Visual C# library project klasy o nazwie "ClassLibrary1" w tym folderze.Należy również otworzyć projekt w Visual Studio zintegrowane środowisko dewelopowania (IDE) przed uruchomieniem tego dodatku.

Aby uzyskać więcej informacji o sposobach uruchamiania w tym przykładzie jako dodatek, zobacz Jak: skompilować i uruchomić przykłady kodu modelu obiektu automatyzacji.

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)
    solnFolderDTEExample(_applicationObject)
End Sub
Sub solnFolderDTEExample(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.")
        MsgBox("The main window caption, obtained through the  _
        DTE object is: " & SF.DTE.MainWindow.Caption)
    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;
    solnFolderDTEExample(_applicationObject);
}
public void solnFolderDTEExample(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 main window caption, obtained through 
the DTE object is: " + SF.DTE.MainWindow.Caption);
    
    catch(SystemException ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

SolutionFolder Interfejs

Przestrzeń nazw EnvDTE80