public static void Run() { var tplSource = typeof(JSTemplate).GetText("_source.js"); var tpl = new FileTemplateStringContentSource(@"..\..\Source\Testing\Manual\ConsoleTest\Templatization\JS\_source.js"); var config = CONFIG.AsLaconicConfig(); var type = typeof(TextJSTemplateCompiler); var args = new object[] { tpl };//new TemplateStringContentSource(tplSource)}; var cmp = FactoryUtils.MakeAndConfigure <TextJSTemplateCompiler>(config, type, args); cmp.Compile(); var unit = cmp.First(); if (unit.CompilationException != null) { Console.WriteLine(unit.CompilationException.ToMessageWithType()); } else { Console.WriteLine(unit.CompiledSource); File.WriteAllText(@"..\..\Source\Testing\Manual\ConsoleTest\Templatization\JS\compiled.js", unit.CompiledSource); Console.WriteLine("Saved to file"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); } }
private static void run(string[] args) { var config = new CommandArgsConfiguration(args); ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Welcome.txt")); if (config.Root["?"].Exists || config.Root["h"].Exists || config.Root["help"].Exists) { ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Help.txt")); return; } if (!config.Root.AttrByIndex(0).Exists) { ConsoleUtils.Error("Template source path is missing"); return; } var files = getFiles(config.Root); var ctypename = config.Root["c"].AttrByIndex(0).Value ?? config.Root["compiler"].AttrByIndex(0).Value; var ctype = string.IsNullOrWhiteSpace(ctypename)? typeof(Azos.Templatization.TextCSTemplateCompiler) : Type.GetType(ctypename); if (ctype == null) { throw new AzosException("Can not create compiler type: " + (ctypename ?? "<none>")); } var compiler = Activator.CreateInstance(ctype) as TemplateCompiler; var onode = config.Root["options"]; if (!onode.Exists) { onode = config.Root["o"]; } if (onode.Exists) { ConfigAttribute.Apply(compiler, onode); var asms = onode.AttrByName("ref").ValueAsString(string.Empty).Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var asm in asms) { compiler.ReferenceAssembly(asm); } } showOptions(compiler); foreach (var f in files) { var src = new FileTemplateStringContentSource(f); ConsoleUtils.Info("Included: " + src.GetName(50)); compiler.IncludeTemplateSource(src); } compiler.Compile(); if (compiler.HasErrors) { showErrors(compiler, config.Root); return; } if (config.Root["src"].Exists) { writeToDiskCompiledSourceFiles(compiler, config.Root); } }
private static void run(string[] args) { var config = new CommandArgsConfiguration(args); ConsoleUtils.WriteMarkupContent( typeof(Program).GetText("Welcome.txt") ); if (config.Root["?"].Exists || config.Root["h"].Exists || config.Root["help"].Exists) { ConsoleUtils.WriteMarkupContent( typeof(Program).GetText("Help.txt") ); return; } if (!config.Root.AttrByIndex(0).Exists) { ConsoleUtils.Error("Template source path is missing"); return; } var files = getFiles(config.Root); var ctypename = config.Root["c"].AttrByIndex(0).Value ?? config.Root["compiler"].AttrByIndex(0).Value; var ctype = string.IsNullOrWhiteSpace(ctypename)? typeof(NFX.Templatization.TextCSTemplateCompiler) : Type.GetType(ctypename); if (ctype == null) throw new NFXException("Can not create compiler type: " + (ctypename??"<none>")); var compiler = Activator.CreateInstance(ctype) as TemplateCompiler; var onode = config.Root["options"]; if (!onode.Exists) onode = config.Root["o"]; if (onode.Exists) { ConfigAttribute.Apply(compiler, onode); var asms = onode.AttrByName("ref").ValueAsString(string.Empty).Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries); foreach(var asm in asms) compiler.ReferenceAssembly(asm); } showOptions(compiler); foreach(var f in files) { var src = new FileTemplateStringContentSource(f); ConsoleUtils.Info("Included: " + src.GetName(50)); compiler.IncludeTemplateSource(src); } compiler.Compile(); if (compiler.HasErrors) { showErrors(compiler, config.Root); return; } if (config.Root["src"].Exists) writeToDiskCompiledSourceFiles(compiler, config.Root); }