/// <summary> /// Initializes a new instance of the <see cref="JsonTransformer"/> class with an external logger /// </summary> /// <param name="logger">The external logger</param> public JsonTransformer(ITransformationLogger logger) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.logger = new JsonShimLogger(logger); }
/// <summary> /// Initializes a new instance of the <see cref="XmlTransformer"/> class with an external logger. /// </summary> /// <param name="logger">External logger. Passed into the transformation</param> /// <param name="useSections">Wheter or not to use sections while logging</param> public XmlTransformer(ITransformationLogger logger, bool useSections) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.logger = new XmlShimLogger(logger, useSections); }
/// <summary> /// Gets the appropriate <see cref="ITransformer"/> for the given transformation /// </summary> /// <param name="source">Path to the file to be transformed</param> /// <param name="logger">Logger to be used in the transformer</param> /// <returns>The appropriate transformer for the given file</returns> public static ITransformer GetTransformer(string source, ITransformationLogger logger) { if (string.IsNullOrWhiteSpace(source)) { throw new ArgumentException(nameof(source)); } return(TransformerCatalog.FirstOrDefault(tr => tr.IsFileSupported(source))?.WithLogger(logger) ?? throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.ErrorMessage_UnsupportedFile, source))); }
/// <inheritdoc/> public ITransformer WithLogger(ITransformationLogger logger) { if (logger == this.logger) { return(this); } else if (logger == null) { return(new JsonTransformer()); } else { return(new JsonTransformer(logger)); } }
/// <summary> /// Initializes a new instance of the <see cref="XmlShimLogger"/> class. /// </summary> /// <param name="logger">Our own logger</param> /// <param name="useSections">Wheter or not to use sections</param> public XmlShimLogger(ITransformationLogger logger, bool useSections) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.useSections = useSections; }
/// <summary> /// Initializes a new instance of the <see cref="JsonShimLogger"/> class. /// </summary> /// <param name="logger">Our own logger</param> public JsonShimLogger(ITransformationLogger logger) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }