Qgen Lite

post_id: 200 / post_date: 2014-07-09

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()
            var ofd = new OpenFileDialog { InitialDirectory = path };
            if (ofd.ShowDialog() == DialogResult.Cancel)
                MessageBox.Show("Nothing selected. exiting");

            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);

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