Esempio n. 1
0
        public static void Run()
        {
            CodeBuilderConfiguration configuration = CodeBuilderConfiguration.Instance;

            for (int i = 0; i < configuration.Tasks.Count; i++)
            {
                TemplateGenerator generator = TemplateFactory.CreateObject(
                    configuration.Tasks[i].Name,
                    configuration.Tasks[i].Generator,
                    configuration);

                ITemplateObserver observer;

                foreach (TaskObserver item in configuration.Tasks[i].Observeres)
                {
                    switch (item.Type)
                    {
                    case "Console":
                        observer = new ConsoleObserver();
                        generator.AddObserver(observer);
                        break;

                    case "File":
                        observer = new FileObserver(configuration.Tasks[i]);
                        generator.AddObserver(observer);
                        break;

                    default:
                        break;
                    }
                }

                generator.Generate();
            }
        }
 private static void Match(string template, string regex)
 {
     TemplateGenerator
     .Generate(template)
     .Should()
     .MatchRegex(regex);
 }
Esempio n. 3
0
 public void When_files_is_null_should_throw_argument_null_exception()
 {
     var writer = new StringWriter();
     var generator = new TemplateGenerator(writer);
     Action method = () => generator.Generate(null);
     method.ShouldThrow<ArgumentNullException>()
         .And.ParamName.Should().Be("files");
 }
Esempio n. 4
0
        private void templateGenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[]          lines     = txtDocument.Lines;
            TemplateGenerator generator = new TemplateGenerator(lines);

            generator.Import();
            lines             = generator.Generate();
            txtDocument.Lines = lines;
        }
Esempio n. 5
0
        public void TemplateWriteTest()
        {
            var expectedWb = new XSSFWorkbook(Expected.TemplateListPath);

            var listGenerator = new TemplateGenerator();
            var generatedWb   = listGenerator.Generate(Expected.GenTemplatePath, Expected.Data);

            AssertWorkbookEquals(expectedWb, generatedWb);
        }
Esempio n. 6
0
    private void Start()
    {
        TemplateGenerator generator = new TemplateGenerator();

        levelBounds = generator.Generate(this);

        EventManager.Instance.SignalEvent(GameEvent.LevelGenerated, this);

        FillPathCellInfo();
    }
        public override void Process(TagHelperContext context, TagHelperOutput?output)
        {
            _ = output ?? throw new ArgumentNullException(nameof(output));
            _ = Name ?? throw new NullReferenceException(nameof(Name));
            _ = Label ?? throw new NullReferenceException(nameof(Label));
            _ = Class ?? throw new NullReferenceException(nameof(Class));

            output.TagName = string.Empty;
            var template = TemplateGenerator.Generate(Name, Label, Class, Value, IsDisabled, ErrorMessage, CompareTo);

            output.Content.SetHtmlContent(template);
        }
Esempio n. 8
0
        public bool GenerateClassMap(string aNameSpace, String aOutPutPath)
        {
            IEnumerable <StoredProcedure> _ts = StoredProcedureRepository.GetStoredProcedures();

            foreach (StoredProcedure _t in _ts)
            {
                String _value = TemplateGenerator.Generate(aNameSpace, _t);
                File.WriteAllText(Path.Combine(aOutPutPath, _t.Name + ".cs"), _value);
            }

            return(true);
        }
Esempio n. 9
0
        public void Given_one_content_when_generate_writer_should_contains_all_contents()
        {
            var writer = new StringWriter();
            var generator = new TemplateGenerator(writer);
            var contents = new []
            {
                new FileContent { Name = "template.tpl.html", Content = "<p>Hi!</p>" }
            };

            generator.Generate(contents);

            writer.GetStringBuilder()
                .ToString()
                .Should().Be("<p>Hi!</p>");
        }
Esempio n. 10
0
        static void Main()
        {
            var te = new TemplateGenerator();
            CustomTemplateBase template;

            using (var sr = new StreamReader(File.OpenRead("sample-template.cshtml")))
            {
                template = te.Generate("OrderInfoTemplate", "Dave", sr, new [] { "ConsoleApplication1.exe" });
            }
            for (var i = 0; i < 4; i++)
            {
                template.Reset();
                template.Model = SampleOrder();
                template.Execute();

                Console.WriteLine("-------");
                Console.WriteLine(template.Body.Trim());
                Console.WriteLine("-------");
            }
        }
Esempio n. 11
0
 private void CodeGeneratorForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         try
         {
             templateGenerator.Generate(
                 nameTextBox.Text,
                 authorTextBox.Text,
                 (string)factionCombo.SelectedItem,
                 (string)languageCombo.SelectedItem,
                 (string)programmingLanguageCombo.SelectedItem,
                 (string)environmentComboBox.SelectedItem,
                 outputTextBox.Text);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             e.Cancel = true;
         }
     }
 }