public MetricResult Calculate(IEnumerable <AssemblyDefinition> assemblies, IMetric metric)
        {
            List <AssemblyResult> assemblyResults = new List <AssemblyResult>();

            foreach (AssemblyDefinition assembly in assemblies)
            {
                List <ModuleResult> moduleResults = new List <ModuleResult>();
                foreach (ModuleDefinition module in assembly.Modules)
                {
                    List <TypeResult> typeResults = new List <TypeResult>();
                    foreach (TypeDefinition type in module.Types)
                    {
                        List <MethodResult> methodResults = new List <MethodResult>();
                        foreach (MethodDefinition method in type.Methods)
                        {
                            MethodResult methodResult = metric.ProcessMethod(method);
                            methodResults.Add(methodResult);
                        }
                        TypeResult typeResult = metric.ProcessType(type, methodResults.ToArray());
                        typeResults.Add(typeResult);
                    }
                    ModuleResult moduleResult = metric.ProcessModule(module, typeResults.ToArray());
                    moduleResults.Add(moduleResult);
                }
                AssemblyResult assemblyResult = metric.ProcessAssembly(assembly, moduleResults.ToArray());
                assemblyResults.Add(assemblyResult);
            }
            MetricResult result = metric.Process(assemblyResults.ToArray());

            return(result);
        }
 public AssemblyResult ProcessAssembly(AssemblyDefinition assembly, ModuleResult[] moduleResults)
 {
     AssemblyResult result = new AssemblyResult(assembly.Name.Name);
     result.ModuleResults = moduleResults;
     result.Result = moduleResults.Sum(r => r.Result);
     return result;
 }
 public ModuleResult ProcessModule(ModuleDefinition module, TypeResult[] typeResults)
 {
     ModuleResult result = new ModuleResult(module.Name);
     result.TypeResults = typeResults;
     result.Result = typeResults.Sum(r => r.Result);
     return result;
 }
Exemple #4
0
        public ModuleResult ProcessModule(ModuleDefinition module, TypeResult[] typeResults)
        {
            ModuleResult result = new ModuleResult(module.Name);

            result.TypeResults = typeResults;
            result.Result      = typeResults.Sum(r => r.Result);
            return(result);
        }