public ParametersParser(OutputLog log) { _log = log; }
public TransformationLogger(OutputLog log) { _log = log; }
private static int Main(string[] args) { var argumentsLoader = new ArgumentsLoader(); if (!argumentsLoader.Load(args)) { return(4); } OutputLog log; if (argumentsLoader.Verbose) { log = OutputLog.FromWriter(Console.Out, Console.Error); } else if (argumentsLoader.Quiet) { log = OutputLog.NoLogs(); } else { log = OutputLog.ErrorOnly(Console.Error); } AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) => log.WriteErrorLine("UnhandledException: {0}.", eventArgs.ExceptionObject); try { if (argumentsLoader.AreAllRequiredParametersSet) { var task = new TransformationTask( log, argumentsLoader.SourceFilePath, argumentsLoader.TransformFilePath, argumentsLoader.PreserveWhitespace); if (argumentsLoader.Indent) { task.Indent = argumentsLoader.Indent; task.IndentChars = argumentsLoader.IndentChars; } if (argumentsLoader.DefaultEncoding != null) { task.DefaultEncoding = argumentsLoader.DefaultEncoding; } IDictionary <string, string> parameters = new Dictionary <string, string>(); if (!string.IsNullOrWhiteSpace(argumentsLoader.ParametersString)) { var parser = new ParametersParser(log); parser.ReadParameters(argumentsLoader.ParametersString, parameters); } if (!string.IsNullOrWhiteSpace(argumentsLoader.ParametersFile)) { ParametersLoader.LoadParameters(argumentsLoader.ParametersFile, parameters); } task.SetParameters(parameters); if (!task.Execute(argumentsLoader.DestinationFilePath, argumentsLoader.ForceParametersTask)) { return(4); } } else { ShowToolHelp(); return(1); } return(0); } catch (Exception e) { log.WriteErrorLine("Unexpected exception: {0}.", e); return(4); } }