private void HandlePluginParameters(IDecoderPlugin plugin) { List <string> arguments = (List <string>)plugin.GetRequiredArguments(); if (arguments.Count != 0) { Dictionary <string, string> parameters = new Dictionary <string, string>(); Console.WriteLine("Enter parameters: "); foreach (var arg in arguments) { Console.WriteLine(arg + ": "); parameters[arg] = Console.ReadLine(); } plugin.SetArguments(parameters); } }
/// <summary> /// Gets a list of DecoderPlugins from the response; /// </summary> /// <returns>IEnumerable<IDecoderPlugin></returns> public IEnumerable <IDecoderPlugin> GetListedDecoderPlugins() { var result = new List <IDecoderPlugin>(); IDecoderPlugin plugin = null; foreach (var item in _valueList) { if (item.Key == ResponseParserKeys.Plugin) { if (plugin != null) { result.Add(plugin); } plugin = new DecoderPlugin { Name = item.Value }; } switch (item.Key) { case ResponseParserKeys.MimeType: plugin.SupportedMimeTypes.ToList().Add(item.Value); break; case ResponseParserKeys.Suffix: plugin.SupportedSuffixes.ToList().Add(item.Value); break; default: break; } } if (plugin != null) { result.Add(plugin); } return(result); }
public void DecodeAction(object sender, object contextObject) { IDecoderPlugin decoderPlugin = (IDecoderPlugin)contextObject; HandlePluginParameters(decoderPlugin); IDecoder decoder = decoderPlugin.GetDecoder(); BinaryReader binaryReader = GetInputBinaryReader(inputBinaryPath); TextWriter textWriter = GetOutputTextWriter(pathToWriteDecode); BinaryDecoder binaryDecoder = new BinaryDecoder(decoderPlugin.GetDecoder()); StreamDecoder streamDecoder = new StreamDecoder(binaryDecoder, binaryReader); streamDecoder.Decode(textWriter); Console.WriteLine(decoderPlugin.GetName() + " Finished"); binaryReader.Close(); textWriter.Close(); Console.WriteLine("File modified. Press any key to continue."); Console.ReadLine(); }