public void AddProject(ProjectMetric projectMetric) { _projectMetrics.Add(projectMetric); Interlocked.Increment(ref _numberOfProjects); Interlocked.Add(ref _totalNumberOfFiles, projectMetric.TotalNumberOfFiles); Interlocked.Add(ref _totalSizeOfFiles, projectMetric.TotalSizeOfFiles); Interlocked.Add(ref _totalLinesOfCode, projectMetric.TotalLinesOfCode); }
public ProjectMetric GetProjectMetrics(string projectFilePath) { ProjectMetric result = new ProjectMetric(); try { Project project = new Project(projectFilePath); foreach (ProjectItem item in project.Items.Where( pi => "compile".Equals(pi.ItemType, StringComparison.InvariantCultureIgnoreCase) )) { string extension = Path.GetExtension(item.UnevaluatedInclude); string path = Path.GetDirectoryName(projectFilePath); string itemPath = Path.Combine(path, item.UnevaluatedInclude); ISourceCodeMetricProvider provider = _sourceCodeMetricProviderFactory.GetSourceCodeMetricProvider(extension); SourceCodeMetric metric = provider.GetSourceCodeMetric(itemPath); result.AddSourceCodeMetric(metric); } logger.InfoFormat("Project: {0} - linesOfCode: {1} \t\t numberOfFiles:{2} \t\t totalFileSize:{3}", projectFilePath, result.TotalLinesOfCode, result.TotalNumberOfFiles, result.TotalSizeOfFiles); return result; } catch (Exception exc) { logger.Error(exc); } return result; }