public CodeGeneratorResult Prepare(TemplateEngineConfig inputConfig) { this.config = inputConfig; result = new CodeGeneratorResult(); if (config == null) { return(result.SetError("No Config", "No config for SmartFormatTemplateEngine provided.")); } try { if (File.Exists(config.TemplatePath)) { Logger.Debug("Reading template file " + config.TemplatePath); using (StreamReader fileReader = new StreamReader(config.TemplatePath)) { template = fileReader.ReadToEnd(); fileReader.Close(); if (string.IsNullOrEmpty(template)) { result.SetError("Template Empty", "Template file " + config.TemplatePath + " found but it seems to be empty."); } } } else { result.SetError("Template Not Found", "Template file " + config.TemplatePath + " does not exist."); } } catch (System.Exception ex) { result.SetError("Error Loading Template", "I/O error while trying to load Template file " + config.TemplatePath + "\n" + ex.Message); } return(result); }
public CodeGeneratorResult Prepare (TemplateEngineConfig inputConfig) { this.config = inputConfig; result = new CodeGeneratorResult (); if (config == null) { return result.SetError ("No Config", "No config for SmartFormatTemplateEngine provided."); } try { if (File.Exists (config.TemplatePath)) { Logger.Debug ("Reading template file " + config.TemplatePath); using (StreamReader fileReader = new StreamReader (config.TemplatePath)) { template = fileReader.ReadToEnd (); fileReader.Close (); if (string.IsNullOrEmpty (template)) { result.SetError ("Template Empty", "Template file " + config.TemplatePath + " found but it seems to be empty."); } } } else { result.SetError ("Template Not Found", "Template file " + config.TemplatePath + " does not exist."); } } catch (System.Exception ex) { result.SetError ("Error Loading Template", "I/O error while trying to load Template file " + config.TemplatePath + "\n" + ex.Message); } return result; }
public TemplateLookup (Config config) { this.TemplateConfig = new TemplateEngineConfig (); this.config = config; }