Esempio n. 1
0
        /// <summary>
        /// Load config for template
        /// </summary>
        /// <param name="templateName"></param>
        /// <returns></returns>
        public static TemplateConfigurer LoadTemplateConfig(String templateName)
        {
            var configurer = new TemplateConfigurer(templateName);

            configurer.Load(templateName);
            return(configurer);
        }
Esempio n. 2
0
        void LoadAllTemplate()
        {
            var templates = TemplateConfigurer.LoadAllTemplates();

            cbSupportedTemplates.Items.Clear();
            foreach (var item in templates)
            {
                cbSupportedTemplates.Items.Add(item);
            }
        }
Esempio n. 3
0
        private static VelocityContext GetContext(TemplateConfigurer configurer, DatabaseType type)
        {
            var context = new VelocityContext();

            context.Put("namespace", configurer.Namespace);
            context.Put("string", typeof(String));
            context.Put("fn", typeof(StringUtils));
            context.Put("providerType", String.Format("{0}.{1}", type.GetType().FullName, type));
            return(context);
        }
Esempio n. 4
0
        private void cbTemplateFiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedTemplate = cbSupportedTemplates.SelectedItem as TemplateConfigurer;

            if (null == selectedTemplate)
            {
                return;
            }
            var selectedConfig = cbTemplateFiles.SelectedItem as TemplateConfig;

            rtbTemplate.Text = TemplateConfigurer.LoadTemplateString(selectedTemplate.TemplateName, selectedConfig);
        }
Esempio n. 5
0
        private void SaveTemplateConfig()
        {
            var selectedTemplate = cbSupportedTemplates.SelectedItem as TemplateConfigurer;

            if (null == selectedTemplate)
            {
                return;
            }
            var selectedConfig = cbTemplateFiles.SelectedItem as TemplateConfig;
            var file           = TemplateConfigurer.GetTemplateStringFile(selectedTemplate.TemplateName, selectedConfig);

            using (var sw = new StreamWriter(file))
            {
                sw.Write(rtbTemplate.Text);
            }
        }