ExecuteTemplate() public method

public ExecuteTemplate ( ) : int
return int
Example #1
0
        protected virtual string RunTemplate(IZetboxContext ctx, string templateName, string filename, params object[] args)
        {
            try
            {
                filename = Unidecode(filename);
                var gen = new TemplateExecutor();

                gen.Settings.Add("basetemplatepath", "Zetbox.Generator.Templates");
                gen.Settings.Add("providertemplatenamespace", TemplateProviderNamespace);
                gen.Settings.Add("providertemplateassembly", TemplateProviderAssembly);

                gen.Settings.Add("template", templateName);

                gen.Settings.Add("targetdir", this.CodeBasePath);
                gen.Settings.Add("output", filename);
                gen.Settings.Add("logfile", "TemplateCodegenLog.txt");

                gen.Settings.Add("extrasuffix", ExtraSuffix);
                gen.Settings.Add("namespaces", String.Join(",", RequiredNamespaces.ToArray()));
                gen.Settings.Add("implementationnamespace", "Zetbox.DalProvider." + BaseName);

                gen.Settings.Add("propertydescriptorname", CustomPropertyDescriptorName);

                gen.TemplateParameters = new object[] { ctx }.Concat(args).ToArray();

                gen.ExecuteTemplate();

                return(filename);
            }
            catch (Exception ex)
            {
                var msg = String.Format("Error while rendering template [{0}] to [{1}]", templateName, filename);
                Log.Error(msg, ex);
                throw new InvalidOperationException(msg, ex);
            }
        }
        protected virtual string RunTemplate(IZetboxContext ctx, string templateName, string filename, params object[] args)
        {
            try
            {
                filename = Unidecode(filename);
                var gen = new TemplateExecutor();

                gen.Settings.Add("basetemplatepath", "Zetbox.Generator.Templates");
                gen.Settings.Add("providertemplatenamespace", TemplateProviderNamespace);
                gen.Settings.Add("providertemplateassembly", TemplateProviderAssembly);

                gen.Settings.Add("template", templateName);

                gen.Settings.Add("targetdir", this.CodeBasePath);
                gen.Settings.Add("output", filename);
                gen.Settings.Add("logfile", "TemplateCodegenLog.txt");

                gen.Settings.Add("extrasuffix", ExtraSuffix);
                gen.Settings.Add("namespaces", String.Join(",", RequiredNamespaces.ToArray()));
                gen.Settings.Add("implementationnamespace", "Zetbox.DalProvider." + BaseName);

                gen.Settings.Add("propertydescriptorname", CustomPropertyDescriptorName);

                gen.TemplateParameters = new object[] { ctx }.Concat(args).ToArray();

                gen.ExecuteTemplate();

                return filename;
            }
            catch (Exception ex)
            {
                var msg = String.Format("Error while rendering template [{0}] to [{1}]", templateName, filename);
                Log.Error(msg, ex);
                throw new InvalidOperationException(msg, ex);
            }
        }