Exemplo n.º 1
0
 /// <summary>
 /// Clears all the file and project informations.
 /// </summary>
 public void Clear()
 {
     projects.Clear();
     AddProject(defaultProject);
     excludePatterns.Clear();
     fileCount = 0;
     report    = null;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Counts the required statistical data about the files and projects, and
        /// generates <see cref="CountingResult"/> objects from the results.
        /// </summary>
        /// <exception cref="InvalidFileException">
        /// A source file is missing or has invalid extension.
        /// </exception>
        public void Count()
        {
            int totalLines        = 0;
            int totalCodeLines    = 0;
            int totalCommentLines = 0;
            int totalBlankLines   = 0;

            // Count each project
            foreach (Project project in fileSet.Projects)
            {
                int projectTotalLines   = 0;
                int projectCodeLines    = 0;
                int projectCommentLines = 0;
                int projectBlankLines   = 0;

                // Count each file
                foreach (SourceFile file in project.Files)
                {
                    CountingResult result = ParseFile(file);

                    // Create report object for file
                    projectTotalLines   += result.TotalLines;
                    projectCodeLines    += result.CodeLines;
                    projectCommentLines += result.CommentLines;
                    projectBlankLines   += result.BlankLines;
                    file.Report          = result;
                }

                // Create report object for project
                CountingResult projectResult = new CountingResult(projectTotalLines,
                                                                  projectCodeLines, projectCommentLines, projectBlankLines);
                project.Report = projectResult;

                totalLines        += projectTotalLines;
                totalCodeLines    += projectCodeLines;
                totalCommentLines += projectCommentLines;
                totalBlankLines   += projectBlankLines;
            }

            // Create summary report
            CountingResult summaryResult = new CountingResult(
                totalLines, totalCodeLines, totalCommentLines, totalBlankLines);

            fileSet.Report = summaryResult;
        }