public override bool Execute() { if (!File.Exists(this.Source.ItemSpec)) { Log.LogError(null, null, null, Source, 0, 0, 0, 0, $"file {this.Source} not found"); return(false); } try { this.ReadConfig(); Log.LogMessage($"Loading xml : {this.Source.ItemSpec}"); var mapper = new TypeMapper(this.configuration.Mapping); var rootGen = new LayoutRootGenerator(Namespace); var layoutGen = new LayoutHolderGenerator(mapper, Namespace); rootGen.Generate(this.OutputFile); var result = layoutGen.Generate(this.Source.ItemSpec, this.OutputFile); if (!result) { File.SetLastWriteTime(OutputFile, DateTime.Now); Log.LogMessage($"Skipping generation of {OutputFile} because there is not relevant change in {Source.ItemSpec}."); } return(true); } catch (XmlException xe) { Log.LogMessage("Error (xml): {0}", xe.Message); Log.LogError(null, null, null, Source, xe.LineNumber, xe.LinePosition, 0, 0, $"{xe.Message}"); return(false); } catch (Exception e) { Log.LogMessage("Error: {0}", e.Message); Log.LogError(null, null, null, Source, 0, 0, 0, 0, $"{e.Message}"); return(false); } }
public override bool Execute() { if (!File.Exists(this.Source.ItemSpec)) { Log.LogError(null, null, null, Source, 0, 0, 0, 0, $"file {this.Source} not found"); return(false); } try { this.ReadConfig(); Log.LogMessage($"Loading xml : {this.Source.ItemSpec}"); var mapper = new TypeMapper(this.configuration.Mapping); var rootGen = new LayoutRootGenerator(Namespace); var layoutGen = new LayoutHolderGenerator(mapper, Namespace); rootGen.Generate(this.OutputFile); layoutGen.Generate(this.Source.ItemSpec, this.OutputFile); return(true); } catch (XmlException xe) { Log.LogMessage("Error (xml): {0}", xe.Message); Log.LogError(null, null, null, Source, xe.LineNumber, xe.LinePosition, 0, 0, $"{xe.Message}"); return(false); } catch (Exception e) { Log.LogMessage("Error: {0}", e.Message); Log.LogError(null, null, null, Source, 0, 0, 0, 0, $"{e.Message}"); return(false); } }