Generate() public method

public Generate ( string csharpCode, bool formatOutput = false ) : string
csharpCode string
formatOutput bool
return string
 public void SimpleQuineGenerateNotMinified()
 {
     var generator = new QuineGenerator() { Minified = false };
     var generated = generator.Generate(File.ReadAllText(Path.Combine(QuineTests.PatternsFolder, "CustomQuine.cs")));
     var checkingResult = _cSharpChecker.CheckQuineProgram(generated);
     Assert.IsTrue(checkingResult.HasNotErrors());
 }
 public void SimpleQuineGeneratedMinifiedInput()
 {
     var generator = new QuineGenerator() { };
     var minifier = new Minifier(new MinifierOptions(true) { CommentsRemoving = false, ConsoleApp = true });
     var minified = minifier.MinifyFromString(File.ReadAllText(Path.Combine(QuineTests.PatternsFolder, "CustomQuine.cs")));
     var generated = generator.Generate(minified);
     var checkingResult = _cSharpChecker.CheckQuineProgram(generated);
     Assert.IsTrue(checkingResult.HasNotErrors());
     Assert.IsTrue(!checkingResult.First().Output.Contains(QuineGenerator.Newline));
 }
示例#3
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            string input = tbInput.Text;

            var generator = new QuineGenerator(tbQuineStr.Text, "System.Console.Write", tbKernel.Text, MinifiedInput);
            var extraParams = new List<QuineParam>();
            for (int i = 0; i < dgvExtraParams.Rows.Count; i++)
                if (!string.IsNullOrEmpty(dgvExtraParams[0, i].Value as string) ||
                    !string.IsNullOrEmpty(dgvExtraParams[1, i].Value as string) ||
                    !string.IsNullOrEmpty(dgvExtraParams[2, i].Value as string) ||
                    !string.IsNullOrEmpty(dgvExtraParams[3, i].Value as string))
                {
                    extraParams.Add(new QuineParam(
                    dgvExtraParams[0, i].Value == null ? "" : (string)dgvExtraParams[0, i].Value,
                    dgvExtraParams[1, i].Value == null ? "" : (string)dgvExtraParams[1, i].Value,
                    dgvExtraParams[2, i].Value == null ? "" : (string)dgvExtraParams[2, i].Value,
                    dgvExtraParams[3, i].Value == null ? "" : (string)dgvExtraParams[3, i].Value));
                }
            var output = generator.Generate(input, false, extraParams.ToArray());

            tbOutput.Text = output;
            tbOutputLength.Text = output.Length.ToString();
            tbFormattedOutput.Text = (new Minifier(new MinifierOptions(false))).MinifyFromString(tbOutput.Text);

            btnCompile_Click(btnCompileOutput, e);
        }