public abstract Convert ( Stream input, IResultLogWriter output ) : void | ||
input | Stream | |
output | IResultLogWriter | |
리턴 | void |
/// <summary>Converts a tool log file represented as a stream into the SARIF format.</summary> /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception> /// <exception cref="ArgumentException">Thrown when one or more arguments have unsupported or /// illegal values.</exception> /// <param name="toolFormat">The tool format of the input file.</param> /// <param name="inputStream">A stream that contains tool log contents.</param> /// <param name="outputStream">A stream to which the converted output should be written.</param> /// <param name="pluginAssemblyPath">Path to plugin assembly containing converter types.</param> public void ConvertToStandardFormat( string toolFormat, Stream inputStream, IResultLogWriter outputStream, LoggingOptions loggingOptions = LoggingOptions.None, string pluginAssemblyPath = null) { if (inputStream == null) { throw new ArgumentNullException(nameof(inputStream)); } if (outputStream == null) { throw new ArgumentNullException(nameof(outputStream)); } ConverterFactory factory = CreateConverterFactory(pluginAssemblyPath); ToolFileConverterBase converter = factory.CreateConverter(toolFormat); if (converter != null) { converter.Convert(inputStream, outputStream, loggingOptions); } else { throw new ArgumentException("Unrecognized tool specified: " + toolFormat, nameof(toolFormat)); } }
public static string GetConverterJson(ToolFileConverterBase converter, byte[] inputData) { using (var input = new MemoryStream(inputData)) { using (var output = new StringWriter()) { var json = new JsonTextWriter(output); json.Formatting = Newtonsoft.Json.Formatting.Indented; json.CloseOutput = false; using (var outputWriter = new ResultLogJsonWriter(json)) { converter.Convert(input, outputWriter); } return output.ToString(); } } }
public static ResultLogObjectWriter GetConverterObjects(ToolFileConverterBase converter, byte[] inputData) { var result = new ResultLogObjectWriter(); using (var input = new MemoryStream(inputData)) { converter.Convert(input, result); } return result; }