public static String WriteGeneratedOutput(this ITemplateEngine eng)
        {
            String outputFn = eng.OutputFileName;

            using (var fs = File.Create(outputFn))
            {
                Stream x = eng.ResultAsStream();
                x.Position = 0;
                x.CopyTo(fs);
            }
            return(outputFn);
        }
Example #2
0
        private JObject _loadConfig(ESIndexDefinition index, String fn, out DateTime fileUtcDate)
        {
            if (fn == null)
            {
                fileUtcDate = DateTime.MinValue;
                return(null);
            }
            Engine.ImportLog.Log("Loading config via template. fn={0}", fn);
            fileUtcDate = File.GetLastWriteTimeUtc(fn);
            ITemplateEngine template = Engine.TemplateFactory.CreateEngine();

            template.LoadFromFile(fn);
            var rdr = template.ResultAsStream().CreateJsonReader();

            return(JObject.Load(rdr));
        }
 public static TextReader ResultAsReader(this ITemplateEngine eng)
 {
     return(eng.ResultAsStream().CreateTextReader());
 }