/// <summary>
        /// Find all .cs files in the project, including sub-folders.
        /// </summary>
        private void findFiles(EnvDTE.ProjectItems projectItems, HashSet <FileInfo> files)
        {
            // We look through the items...
            int numProjectItems = Utils.call(() => (projectItems.Count));

            for (int i = 1; i <= numProjectItems; ++i)
            {
                EnvDTE.ProjectItem projectItem = Utils.call(() => (projectItems.Item(i)));

                // We get the full-path...
                EnvDTE.Properties           dteProperties = Utils.call(() => (projectItem.Properties));
                Dictionary <string, object> properties    = getProperties(dteProperties);
                string fullPath           = getStringProperty(properties, "FullPath");
                int    copyToOutputFolder = getIntProperty(properties, "CopyToOutputDirectory");

                // We check if it is a file (it could be a folder instead)...
                if (File.Exists(fullPath) == true)
                {
                    // We add it to the list of files...
                    FileInfo fileInfo = new FileInfo();
                    fileInfo.AbsolutePath       = fullPath;
                    fileInfo.RelativePath       = Utils.makeRelativePath(m_projectInfo.RootFolderAbsolute, fullPath);
                    fileInfo.CopyToOutputFolder = (copyToOutputFolder != 0);
                    files.Add(fileInfo);
                }

                // We see if the item itself has sub-items...
                EnvDTE.ProjectItems subItems = Utils.call(() => (projectItem.ProjectItems));
                if (subItems != null)
                {
                    findFiles(subItems, files);
                }

                // We see if this item has a sub-project...
                EnvDTE.Project subProject = Utils.call(() => (projectItem.SubProject));
                if (subProject != null)
                {
                    EnvDTE.ProjectItems subProjectItems = Utils.call(() => (subProject.ProjectItems));
                    findFiles(subProjectItems, files);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Find all .cs files in the project, including sub-folders.
        /// </summary>
        private void findFiles(EnvDTE.ProjectItems projectItems, HashSet<FileInfo> files)
        {
            // We look through the items...
            int numProjectItems = Utils.call(() => (projectItems.Count));
            for (int i = 1; i <= numProjectItems; ++i)
            {
                EnvDTE.ProjectItem projectItem = Utils.call(() => (projectItems.Item(i)));

                // We get the full-path...
                EnvDTE.Properties dteProperties = Utils.call(() => (projectItem.Properties));
                Dictionary<string, object> properties = getProperties(dteProperties);
                string fullPath = getStringProperty(properties, "FullPath");
                int copyToOutputFolder = getIntProperty(properties, "CopyToOutputDirectory");

                // We check if it is a file (it could be a folder instead)...
                if (File.Exists(fullPath) == true)
                {
                    // We add it to the list of files...
                    FileInfo fileInfo = new FileInfo();
                    fileInfo.AbsolutePath = fullPath;
                    fileInfo.RelativePath = Utils.makeRelativePath(m_projectInfo.RootFolderAbsolute, fullPath);
                    fileInfo.CopyToOutputFolder = (copyToOutputFolder != 0);
                    files.Add(fileInfo);
                }

                // We see if the item itself has sub-items...
                EnvDTE.ProjectItems subItems = Utils.call(() => (projectItem.ProjectItems));
                if (subItems != null)
                {
                    findFiles(subItems, files);
                }

                // We see if this item has a sub-project...
                EnvDTE.Project subProject = Utils.call(() => (projectItem.SubProject));
                if (subProject != null)
                {
                    EnvDTE.ProjectItems subProjectItems = Utils.call(() => (subProject.ProjectItems));
                    findFiles(subProjectItems, files);
                }
            }
        }