예제 #1
0
 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;
		}
예제 #3
0
		public TemplateLookup (Config config) {
			this.TemplateConfig = new TemplateEngineConfig ();
			this.config = config;
		}