using System.Collections.Generic; using Codelyzer.Analysis; using CTA.Rules.Config; namespace CTA.Rules.Metrics { public class MetricsContext { public string SolutionPath { get; set; } public string SolutionPathHash { get; set; } public Dictionary ProjectGuidMap { get; set; } public MetricsContext(string solutionPath) { SolutionPath = solutionPath; SolutionPathHash = EncryptionHelper.ConvertToSHA256Hex(solutionPath); ProjectGuidMap = new Dictionary(); } public MetricsContext(string solutionPath, IEnumerable analyzerResults) { SolutionPath = solutionPath; SolutionPathHash = EncryptionHelper.ConvertToSHA256Hex(solutionPath); SetProjectGuidMap(analyzerResults); } public void AddProjectToMap(AnalyzerResult analyzerResult) { var projectName = analyzerResult.ProjectResult.ProjectFilePath; var projectGuid = analyzerResult.ProjectResult.ProjectGuid; ProjectGuidMap[projectName] = projectGuid; } private void SetProjectGuidMap(IEnumerable analyzerResults) { ProjectGuidMap = new Dictionary(); foreach (var analyzerResult in analyzerResults) { var projectName = analyzerResult.ProjectResult.ProjectFilePath; var projectGuid = analyzerResult.ProjectResult.ProjectGuid; ProjectGuidMap[projectName] = projectGuid; } } } }