Esempio n. 1
0
        /// <summary>
        /// Not currently used, but will be the basis for user defined templates. Please don't remove!
        /// </summary>
        /// <param name="templateFile">The template file.</param>
        /// <param name="values">The values.</param>
        /// <param name="language">The language.</param>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        public static string RunTemplate(string templateFile, NameValueCollection values, ICodeLanguage language, DataProvider provider)
        {
            string templatePath = Path.Combine(TemplateDirectory, templateFile);
            string templateText = Files.GetFileText(templatePath);

            for (int i = 0; i < values.Count; i++)
            {
                templateText = templateText.Replace(values.GetKey(i), values.Get(i));
            }

            TurboTemplate t = new TurboTemplate(templateText, language, provider);

            return(t.Render());
        }
Esempio n. 2
0
        /// <summary>
        /// Runs the template.
        /// </summary>
        /// <param name="templateType">Type of the template.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="language">The language.</param>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        public static string RunTemplate(TemplateType templateType, IEnumerable <Replacement> settings, ICodeLanguage language, DataProvider provider)
        {
            Utility.WriteTrace("Getting Template");
            string templateText = GetTemplateText(templateType, language);

            Utility.WriteTrace("Replacing values in template");
            foreach (Replacement var in settings)
            {
                string replaceHolder = String.Concat("#", Enum.GetName(typeof(ReplacementVariable), var.Variable).ToUpper(new CultureInfo("en")), "#");
                templateText = Utility.FastReplace(templateText, replaceHolder, var.ReplaceWith, StringComparison.InvariantCultureIgnoreCase);
            }

            TurboTemplate t = new TurboTemplate(templateText, language, provider);

            Utility.WriteTrace("Rendering template");
            string output = t.Render();

            Utility.WriteTrace("Finished :)");
            return(output);
        }
Esempio n. 3
0
        /// <summary>
        /// Runs the structs.
        /// </summary>
        /// <param name="language">The language.</param>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        public static string RunStructs(ICodeLanguage language, DataProvider provider)
        {
            TurboTemplate tt = BuildStructsTemplate(language, provider);

            return(tt.Render());
        }
Esempio n. 4
0
        /// <summary>
        /// Runs the class.
        /// </summary>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="language">The language.</param>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        public static string RunClass(string tableName, ICodeLanguage language, DataProvider provider)
        {
            TurboTemplate tt = BuildClassTemplate(tableName, language, provider);

            return(tt.Render());
        }
Esempio n. 5
0
        /// <summary>
        /// Runs the read only.
        /// </summary>
        /// <param name="viewName">Name of the view.</param>
        /// <param name="language">The language.</param>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        public static string RunReadOnly(string viewName, ICodeLanguage language, DataProvider provider)
        {
            TurboTemplate tt = BuildViewTemplate(viewName, language, provider);

            return(tt.Render());
        }