public void LogMessage(string message, params object[] messageArgs) { if (externalLogger != null) { externalLogger.LogMessage(message, messageArgs); } }
public bool Execute() { bool flag = true; IXmlTransformationLogger logger = (IXmlTransformationLogger) new Log4netTransformationLogger(); try { logger.StartSection(string.Format((IFormatProvider)CultureInfo.CurrentCulture, "Transforming Source File: {0}", new object[1] { (object)this.Source }), new object[0]); XmlTransformableDocument document = this.OpenSourceFile(this.Source); logger.LogMessage(string.Format((IFormatProvider)CultureInfo.CurrentCulture, "Applying Transform File: {0}", new object[1] { (object)this.Transform }), new object[0]); flag = this.OpenTransformFile(this.Transform, logger).Apply((XmlDocument)document); if (flag) { logger.LogMessage(string.Format((IFormatProvider)CultureInfo.CurrentCulture, "Output File: {0}", new object[1] { (object)this.Destination }), new object[0]); this.SaveTransformedFile(document, this.Destination); } } catch (XmlException ex) { Uri uri = new Uri(ex.SourceUri); logger.LogError(uri.LocalPath, ex.LineNumber, ex.LinePosition, ex.Message, new object[0]); flag = false; } catch (Exception ex) { logger.LogErrorFromException(ex); flag = false; } finally { logger.EndSection(string.Format((IFormatProvider)CultureInfo.CurrentCulture, flag ? "Transformation succeeded" : "Transformation failed", new object[0]), new object[0]); } return(flag); }
public bool Run(Options opts) { if (opts == null) { throw new ArgumentNullException(nameof(opts)); } _logger.LogMessage($"Applying {opts.TransformFile} to {opts.SourceFile} with output to {opts.DestinationFile}"); if (!_filesystemAdapter.FileExist(opts.SourceFile)) { _logger.LogError($"Source file {opts.SourceFile} does not exist."); return(false); } if (!_filesystemAdapter.FileExist(opts.TransformFile)) { _logger.LogError($"Transform file {opts.TransformFile} does not exist."); return(false); } var src = new XmlTransformableDocument { PreserveWhitespace = true }; src.Load(opts.SourceFile); var transform = new XmlTransformation(opts.TransformFile, _logger); bool success = transform.Apply(src); if (success) { src.Save(opts.DestinationFile); return(true); } return(false); }
public void LogMessage(string message, params object[] messageArgs) => _externalLogger?.LogMessage(message, messageArgs);