2015-12-16 02:09:08 +00:00
|
|
|
|
using System.Collections.Generic;
|
2015-12-11 03:01:40 +00:00
|
|
|
|
using Microsoft.DotNet.ProjectModel;
|
|
|
|
|
using MultiProjectValidator.AnalysisRules;
|
|
|
|
|
|
|
|
|
|
namespace MultiProjectValidator
|
|
|
|
|
{
|
|
|
|
|
public class ProjectAnalyzer
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static ProjectAnalyzer Create(List<ProjectContext> projectContexts)
|
|
|
|
|
{
|
|
|
|
|
// Any Additional rules would be added here
|
|
|
|
|
var rules = new List<IAnalysisRule>
|
|
|
|
|
{
|
|
|
|
|
new DependencyMismatchRule()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new ProjectAnalyzer(rules, projectContexts);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-16 22:10:39 +00:00
|
|
|
|
private List<ProjectContext> _projectContexts;
|
|
|
|
|
private List<IAnalysisRule> _rules;
|
2015-12-11 03:01:40 +00:00
|
|
|
|
|
|
|
|
|
private ProjectAnalyzer(List<IAnalysisRule> rules, List<ProjectContext> projectContexts)
|
|
|
|
|
{
|
2015-12-16 22:10:39 +00:00
|
|
|
|
_rules = rules;
|
|
|
|
|
_projectContexts = projectContexts;
|
2015-12-11 03:01:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<AnalysisResult> DoAnalysis()
|
|
|
|
|
{
|
|
|
|
|
var results = new List<AnalysisResult>();
|
|
|
|
|
|
2015-12-16 22:10:39 +00:00
|
|
|
|
foreach(var rule in _rules)
|
2015-12-11 03:01:40 +00:00
|
|
|
|
{
|
2015-12-16 22:10:39 +00:00
|
|
|
|
results.Add(rule.Evaluate(_projectContexts));
|
2015-12-11 03:01:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|