QGen Lite

QGen uses string.format to generate code. It can be replaced with T4 but still has its own charm.
I rewrote it today stripping it to bare essentials. You can also see it on gist.github.com

       static void Main()
        {
        start:
            var ofd = new OpenFileDialog { InitialDirectory = path };
            if (ofd.ShowDialog() == DialogResult.Cancel)
            {
                MessageBox.Show("Nothing selected. exiting");
                return;
            }

            var fmt = File.ReadAllText(ofd.FileName);
            var lines = File.ReadAllLines(Path.Combine(path, "fields.txt"));
            var op = string.Empty;
            foreach (var line in lines)
            {
                op += string.Format(fmt, line.Split('	')).Replace("<<", "{").Replace(">>", "}");
            }
            var file = Path.ChangeExtension(ofd.FileName, "gen.txt");
            File.WriteAllText(file, op);
            System.Diagnostics.Process.Start(file);

            if (MessageBox.Show("Again?", "Cselian Ivy AIO Lite", MessageBoxButtons.YesNo) == DialogResult.Yes)
                goto start;
        }

Leave a Comment