public void WriteAllBaselineComparisons(string reportDir, string newCommand)
        {
            if (!Directory.Exists(reportDir))
            {
                Directory.CreateDirectory(reportDir);
            }

            // write the comparisons for the commands
            List <InvocationBaselineUnit> invocationBaselineUnitList = new List <InvocationBaselineUnit>();

            foreach (InvocationUnit unit in _invocationUnits)
            {
                IReadOnlyList <BaselineCommandData> unitCommandData = WriteBaselineComparisonsForInvocationUnit(unit, reportDir, newCommand);
                InvocationBaselineUnit reportUnit = new InvocationBaselineUnit(unit.Name, unit.InstallRequirements, unitCommandData);
                invocationBaselineUnitList.Add(reportUnit);
            }

            // write the master baseline report.
            BaselineMasterReport masterBaseline = new BaselineMasterReport()
            {
                NewCommand  = newCommand,
                Invocations = invocationBaselineUnitList
            };
            JObject serializedMaster = JObject.FromObject(masterBaseline);

            string masterBaselineReportFilename = Path.Combine(reportDir, MasterBaselineReportFileName);

            File.WriteAllText(masterBaselineReportFilename, serializedMaster.ToString());
        }
        public static BaselineMasterReport FromJObject(JObject source)
        {
            string newCommand = source.GetValue(nameof(NewCommand)).ToString();

            List <InvocationBaselineUnit> invocationUnitList = new List <InvocationBaselineUnit>();

            foreach (JToken unitJObject in source.GetValue(nameof(Invocations)))
            {
                InvocationBaselineUnit invocationUnit = InvocationBaselineUnit.FromJObject((JObject)unitJObject);
                invocationUnitList.Add(invocationUnit);
            }

            return(new BaselineMasterReport()
            {
                NewCommand = newCommand,
                Invocations = invocationUnitList
            });
        }
Пример #3
0
 public static InvocationUnit FromInvocationBaselineUnit(InvocationBaselineUnit baselinUnit)
 {
     return(new InvocationUnit(baselinUnit.Name, baselinUnit.InstallRequirements, baselinUnit.Invocations.Select(x => x.Command).ToList()));
 }