public static ResultLogObjectWriter GetConverterObjects(ToolFileConverterBase converter, byte[] inputData) { var result = new ResultLogObjectWriter(); using (var input = new MemoryStream(inputData)) { converter.Convert(input, result, OptionallyEmittedData.None); } return(result); }
// Create the converter for the specified toolFormat, if possible; // otherwise, delegate to the next converter in the Chain of Responsibility, // if any. public ToolFileConverterBase CreateConverter(string toolFormat) { ToolFileConverterBase converter = this.CreateConverterCore(toolFormat); if (converter != null) { return(converter); } if (this.Next != null) { return(this.Next.CreateConverter(toolFormat)); } return(null); }
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, LoggingOptions.None); } return(output.ToString()); } } }
public void BuiltInConverterFactory_HasMatchingConverterTypeNamesForAllRegisteredToolFormats() { foreach (string toolFormat in Utilities.GetToolFormats()) { Lazy <ToolFileConverterBase> lazyConverter; // There's another test that ensures that all the required keys do in fact exist. if (BuiltInConverterFactory.BuiltInConverters.TryGetValue(toolFormat, out lazyConverter)) { // The only way to tell what subtype of ToolFileConverterBase is stored in each dictionary // entry is to instantiate it. Accessing the "Value" property of a Lazy<T> instantiates the object. ToolFileConverterBase converter = lazyConverter.Value; string expectedConverterTypeName = toolFormat.ConverterTypeName(); string actualConverterTypeName = converter.GetType().Name; Assert.Equal(expectedConverterTypeName, actualConverterTypeName); } } }
public static ResultLogObjectWriter GetConverterObjects(ToolFileConverterBase converter, string inputData) { return(GetConverterObjects(converter, Encoding.UTF8.GetBytes(inputData))); }
public static string GetConverterJson(ToolFileConverterBase converter, string inputData) { return(GetConverterJson(converter, Encoding.UTF8.GetBytes(inputData))); }