Exemplo n.º 1
0
        public async Task UpdateMenuTemplate(TemplateInput input)
        {
            if (!string.IsNullOrEmpty(input.MenuGuid))
            {
                var menuItemDefine = await _menuRepository.SingleAsync(c => c.MenuGuid == input.MenuGuid);

                if (menuItemDefine != null)
                {
                    if (input.TemplType == "IndexPageTemplate")
                    {
                        menuItemDefine.IndexPageTemplate = input.Content;
                    }
                    else if (input.TemplType == "CreatePageTemplate")
                    {
                        menuItemDefine.CreatePageTemplate = input.Content;
                    }
                    else if (input.TemplType == "UpdatePageTemplate")
                    {
                        menuItemDefine.UpdatePageTemplate = input.Content;
                    }
                    else if (input.TemplType == "GeneralPageTemplate")
                    {
                        menuItemDefine.GeneralPageTemplate = input.Content;
                    }

                    await _menuRepository.UpdateAsync(menuItemDefine);
                }
            }
        }
        public CodeGenDialog(TemplateInput input)
        {
            InitializeComponent();
            templateInput = input;

            runEngine(input, Resources.Template_CS);
        }
        private void runEngine(TemplateInput input, string template)
        {
            TemplateEngine engine = new TemplateEngine();

            engine.Template = template;
            string output = engine.Process(input);

            txtOutput.Text = output;
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            TemplateInput input = new TemplateInput();

            input.Pattern      = results.RegexText;
            input.RegexOptions = results.RegXOptions;
            input.Input        = results.SampleText;

            CodeGenDialog dlg = new CodeGenDialog(input);

            dlg.ShowDialog(this);
        }
Exemplo n.º 5
0
        public async Task AddTemplate(TemplateInput input)
        {
            if (string.IsNullOrEmpty(input.Content))
            {
                input.Content = string.Empty;
            }

            if (!string.IsNullOrEmpty(input.CopyFrom))
            {
                input.Content = (await _templateManager.GetTemplateContentAsync(input.CopyFrom)).Content;
            }

            var template = await _templateManager.GetTemplateContentAsync(input.TemplateName);

            if (template != null)
            {
                template.Content = input.Content;
                var resultEdit = await _templateManager.EditTemplate(template);

                if (resultEdit.HasError)
                {
                    throw new UserFriendlyException(L(resultEdit.ErrorMessage));
                }
                return;
            }

            var result = await _templateManager.AddTemplate(new TemplateInfo()
            {
                Content   = input.Content,
                IsPartial = input.IsPartial,
                Name      = input.TemplateName.Sluggify(),
            });

            if (result.HasError)
            {
                throw new UserFriendlyException(L(result.ErrorMessage));
            }
        }
 public void setup()
 {
     engine = new TemplateEngine();
     input = new TemplateInput();
 }
 public void setup()
 {
     engine = new TemplateEngine();
     input  = new TemplateInput();
 }