public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { CLIAnalyzeCmdOptions cLIAnalyzeCmdOptions = (CLIAnalyzeCmdOptions)commandOptions; AnalyzeResult analyzeResult = (AnalyzeResult)result; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; if (string.IsNullOrEmpty(commandOptions.OutputFilePath)) { WriteOnce.Result("Results"); } if (cLIAnalyzeCmdOptions.SimpleTagsOnly) { List <string> keys = new List <string>(analyzeResult.Metadata.UniqueTags); keys.Sort(); TagsFile tags = new TagsFile(); tags.Tags = keys.ToArray(); TextWriter.Write(JsonConvert.SerializeObject(tags, Formatting.Indented)); } else { JsonSerializer jsonSerializer = new JsonSerializer(); jsonSerializer.Formatting = Formatting.Indented; jsonSerializer.Serialize(TextWriter, analyzeResult); } WriteOnce.NewLine(); if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { ExportTagsResult exportTagsResult = (ExportTagsResult)result; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; if (exportTagsResult.TagsList.Count > 0) { WriteOnce.Result("Results"); foreach (string tag in exportTagsResult.TagsList) { WriteOnce.General(tag); } } else { WriteOnce.General("No tags found"); } if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { VerifyRulesResult verifyRulesResult = (VerifyRulesResult)result; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; if (string.IsNullOrEmpty(commandOptions.OutputFilePath)) { WriteOnce.Result("Results"); } if (verifyRulesResult.ResultCode != VerifyRulesResult.ExitCode.Verified) { WriteOnce.Any(MsgHelp.GetString(MsgHelp.ID.TAGTEST_RESULTS_FAIL), true, ConsoleColor.Red, WriteOnce.ConsoleVerbosity.Low); } else { WriteOnce.Any(MsgHelp.GetString(MsgHelp.ID.TAGTEST_RESULTS_SUCCESS), true, ConsoleColor.Green, WriteOnce.ConsoleVerbosity.Low); } if (verifyRulesResult.RuleStatusList.Count > 0) { WriteOnce.Result("Rule status"); foreach (RuleStatus ruleStatus in verifyRulesResult.RuleStatusList) { WriteOnce.General(String.Format("Ruleid: {0}, Rulename: {1}, Status: {2}", ruleStatus.RulesId, ruleStatus.RulesName, ruleStatus.Verified)); } } if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { AnalyzeResult analyzeResult = (AnalyzeResult)result; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; if (string.IsNullOrEmpty(commandOptions.OutputFilePath)) { WriteOnce.Result("Results"); } JsonSerializer jsonSerializer = new(); jsonSerializer.Formatting = Formatting.Indented; if (TextWriter != null) { jsonSerializer.Serialize(TextWriter, analyzeResult); } WriteOnce.NewLine(); if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { JsonSerializer jsonSerializer = new JsonSerializer(); jsonSerializer.Formatting = Formatting.Indented; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; if (string.IsNullOrEmpty(commandOptions.OutputFilePath)) { WriteOnce.Result("Results"); } if (TextWriter != null) { if (result is TagTestResult) { jsonSerializer.Serialize(TextWriter, (TagTestResult)result); } else if (result is TagDiffResult) { jsonSerializer.Serialize(TextWriter, (TagDiffResult)result); } else if (result is VerifyRulesResult) { jsonSerializer.Serialize(TextWriter, (VerifyRulesResult)result); } else if (result is ExportTagsResult) { jsonSerializer.Serialize(TextWriter, (ExportTagsResult)result); } else if (result is PackRulesResult packRulesResult) { jsonSerializer.Serialize(TextWriter, packRulesResult.Rules);//write rules array only to disk } else { throw new System.Exception("Unexpected object type for json writer"); } } else { WriteOnce.Log?.Error("Unexpected null TextWriter"); } WriteOnce.NewLine(); if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { JsonSerializer jsonSerializer = new(); jsonSerializer.Formatting = Formatting.Indented; jsonSerializer.NullValueHandling = NullValueHandling.Ignore; jsonSerializer.DefaultValueHandling = DefaultValueHandling.Ignore; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; if (string.IsNullOrEmpty(commandOptions.OutputFilePath)) { WriteOnce.Result("Results"); } if (TextWriter != null) { switch (result) { case TagDiffResult: case ExportTagsResult: case VerifyRulesResult: jsonSerializer.Serialize(TextWriter, result); break; case PackRulesResult prr: jsonSerializer.Serialize(TextWriter, prr.Rules); break; default: throw new System.Exception("Unexpected object type for json writer"); } } else { WriteOnce.Log?.Error("Unexpected null TextWriter"); } WriteOnce.NewLine(); if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { CLITagTestCmdOptions cLITagTestCmdOptions = (CLITagTestCmdOptions)commandOptions; TagTestResult tagTestResult = (TagTestResult)result; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; if (string.IsNullOrEmpty(commandOptions.OutputFilePath)) { WriteOnce.Result("Results"); } WriteOnce.General(MsgHelp.FormatString(MsgHelp.ID.TAGTEST_RESULTS_TEST_TYPE, cLITagTestCmdOptions.TestType), false, WriteOnce.ConsoleVerbosity.Low); if (tagTestResult.ResultCode == TagTestResult.ExitCode.TestFailed) { WriteOnce.Any(MsgHelp.GetString(MsgHelp.ID.TAGTEST_RESULTS_FAIL), true, ConsoleColor.Red, WriteOnce.ConsoleVerbosity.Low); } else { WriteOnce.Any(MsgHelp.GetString(MsgHelp.ID.TAGTEST_RESULTS_SUCCESS), true, ConsoleColor.Green, WriteOnce.ConsoleVerbosity.Low); } if (tagTestResult.TagsStatusList.Count > 0) { WriteOnce.Result("Test results:"); foreach (TagStatus tag in tagTestResult.TagsStatusList) { WriteOnce.General(string.Format("Tag: {0}, Detected: {1}", tag.Tag, tag.Detected)); } } WriteOnce.NewLine(); if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { TagDiffResult tagDiffResult = (TagDiffResult)result; CLITagDiffCmdOptions cLITagDiffCmdOptions = (CLITagDiffCmdOptions)commandOptions; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; if (string.IsNullOrEmpty(commandOptions.OutputFilePath)) { WriteOnce.Result("Results"); } WriteOnce.General(MsgHelp.FormatString(MsgHelp.ID.TAGTEST_RESULTS_TEST_TYPE, cLITagDiffCmdOptions.TestType), false, WriteOnce.ConsoleVerbosity.Low); if (tagDiffResult.ResultCode == TagDiffResult.ExitCode.TestFailed) { WriteOnce.Any(MsgHelp.GetString(MsgHelp.ID.TAGTEST_RESULTS_FAIL), true, ConsoleColor.Red, WriteOnce.ConsoleVerbosity.Low); } else { WriteOnce.Any(MsgHelp.GetString(MsgHelp.ID.TAGTEST_RESULTS_SUCCESS), true, ConsoleColor.Green, WriteOnce.ConsoleVerbosity.Low); } //Results list if (tagDiffResult.TagDiffList.Count > 0) { WriteOnce.Result("Differences"); foreach (TagDiff tagDiff in tagDiffResult.TagDiffList) { WriteOnce.General(string.Format("Tag: {0}, Only found in file: {1}", tagDiff.Tag, tagDiff.Source)); } } if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { CLIAnalyzeCmdOptions cLIAnalyzeCmdOptions = (CLIAnalyzeCmdOptions)commandOptions; AnalyzeResult analyzeResult = (AnalyzeResult)result; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; WriteOnce.Result("Results"); if (cLIAnalyzeCmdOptions.SimpleTagsOnly) { List <string> keys = new List <string>(analyzeResult.Metadata.UniqueTags); keys.Sort(); foreach (string tag in keys) { WriteOnce.General(tag); } } else { WriteAppMeta(analyzeResult.Metadata); WriteDependencies(analyzeResult.Metadata); WriteOnce.General(MakeHeading("Match Details")); foreach (MatchRecord match in analyzeResult.Metadata.Matches) { WriteMatch(match); } } if (autoClose) { FlushAndClose(); } }
public override void WriteResults(Result result, CLICommandOptions commandOptions, bool autoClose = true) { CLIAnalyzeCmdOptions cLIAnalyzeCmdOptions = (CLIAnalyzeCmdOptions)commandOptions; AnalyzeResult analyzeResult = (AnalyzeResult)result; //For console output, update write once for same results to console or file WriteOnce.TextWriter = TextWriter; WriteOnce.Result("Results"); WriteAppMeta(analyzeResult.Metadata); WriteDependencies(analyzeResult.Metadata); WriteOnce.General(MakeHeading("Match Details")); foreach (MatchRecord match in analyzeResult.Metadata.Matches ?? new List <MatchRecord>()) { WriteMatch(match); } if (autoClose) { FlushAndClose(); } }