/// <summary> /// Create new TransformationTask object and set values for <see cref="SourceFilePath"/> and <see cref="TransformFile"/> /// </summary> /// <param name="log">The logger.</param> /// <param name="sourceFilePath">Source file path</param> /// <param name="transformFilePath">Transformation file path</param> public TransformationTask(OutputLog log, string sourceFilePath, string transformFilePath) : this(log) { this.SourceFilePath = sourceFilePath; this.TransformFile = transformFilePath; }
private static int Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly; var argumentsLoader = new ArgumentsLoader(); if (!argumentsLoader.Load(args)) { return(4); } OutputLog log = null; 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; } if (argumentsLoader.IgnoreMissingTransformation) { task.IgnoreMissingTransformation = true; } 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); } }
public TransformationLogger(OutputLog log) { this.log = log; }
/// <summary> /// Empty constructor /// </summary> private TransformationTask(OutputLog log) { _log = log ?? throw new ArgumentNullException(nameof(log)); _transfomrationLogger = new TransformationLogger(log); IndentChars = " "; }
public ParametersParser(OutputLog log) { this.log = log; }
public ParametersParser(OutputLog log) { _log = log; }