コード例 #1
0
        private void Parse(string solutionFile, string[] skip)
        {
            VsSolution solution = VsSolution.Parse(File.ReadAllLines(solutionFile));

            string solutionPath = solutionFile;

            solutionPath = solutionPath.Remove(solutionPath.LastIndexOf('\\'));

            skip = TrimToLower(skip);

            List <ListBoxItemData> allFiles = new List <ListBoxItemData>();

            int  totalLines = 0;
            int  totalItems = 0;
            long totalSize  = 0;

            foreach (VsSolutionProjectPart each in solution.LinkedProjects)
            {
                if (!Contains(skip, each.Name.ToLower().Trim()))
                {
                    string projectPath = solutionPath + "\\" + each.Path;

                    if (File.Exists(projectPath))
                    {
                        VsProject proj = VsProject.Parse(projectPath.Remove(projectPath.LastIndexOf('\\')), File.ReadAllText(projectPath));
                        projectPath = projectPath.Remove(projectPath.LastIndexOf('\\'));

                        ProcessProject(allFiles, ref totalLines, ref totalItems, ref totalSize, each, projectPath, proj);
                    }
                }
            }

            Dispatcher.BeginInvoke(() =>
            {
                files.ItemsSource   = allFiles;
                skipBox.IsEnabled   = solutionPathBox.IsEnabled = browseButton.IsEnabled = parseButton.IsEnabled = true;
                parseButton.Content = "_Parse";
                lineCount.Text      = totalLines.ToString() + " line" + (totalLines != 1 ? "s" : "");
                itemCount.Text      = totalItems.ToString() + " item" + (totalItems != 1 ? "s" : "");
                itemSize.Text       = IOHelpers.FormatFileSize(totalSize);
            });
        }
コード例 #2
0
 private int SizeCompareTo(object size1, object size2)
 {
     return(-1 * IOHelpers.FormatFileSize((string)size1).CompareTo(IOHelpers.FormatFileSize((string)size2)));
 }
コード例 #3
0
        private void ProcessProject(List <ListBoxItemData> allFiles, ref int totalLines, ref int totalItems, ref long totalSize, VsSolutionProjectPart each, string projectPath, VsProject proj)
        {
            foreach (string file in proj.IncludedFiles)
            {
                string   filename = projectPath + "\\" + file;
                FileInfo info     = new FileInfo(filename);

                bool alreadyIndexed = false;

                foreach (ListBoxItemData lbid in allFiles)
                {
                    if (lbid.Path + "\\" + lbid.Name == info.FullName)
                    {
                        alreadyIndexed = true;
                        lbid.Project  += ", " + each.Name;
                        break;
                    }
                }

                if (!alreadyIndexed)
                {
                    int lines = File.ReadAllLines(filename).Length;

                    ListBoxItemData lbid = new ListBoxItemData(info.Name, info.DirectoryName,
                                                               info.LastWriteTime, FileType(filename), IOHelpers.FormatFileSize(info.Length),
                                                               lines, each.Name);

                    totalLines += lines;
                    totalItems++;
                    totalSize += info.Length;

                    allFiles.Add(lbid);
                }
            }

            foreach (VsProject project in proj.IncludedProjects)
            {
                ProcessProject(allFiles, ref totalLines, ref totalItems, ref totalSize, each, projectPath, project);
            }
        }