Imports EnvDTE Imports EnvDTE80 Imports System.Collections.Generic Imports System.Text Public Class Form1 Private dte As DTE2 = System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0") Dim lElements As New List(Of String) Public Enum Sizes Small Medium Large ExtraLarge End Enum Private Sub Test(mysize As Sizes) Dim prova As Sizes 'not found in FileCodeModel prova = Sizes.ExtraLarge 'not found in FileCodeModel End Sub Private Sub RecursiveLoop(cdElements As CodeElements) Dim children As String Dim elem As CodeElement Try For Each elem In cdElements lElements.Add(elem.Name & vbCrLf) RecursiveLoop(elem.Children) Next Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString) End Try End Sub Sub CodeElementsExample(ByVal dte As DTE2) Dim fcm As FileCodeModel = _ dte.ActiveDocument.ProjectItem.FileCodeModel RecursiveLoop(fcm.CodeElements) Dim sBuilder As New StringBuilder For Each item As String In lElements sBuilder.Append(item) Next MsgBox(sBuilder.ToString) End Sub Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load Stop ' open code window CodeElementsExample(dte) End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)