private static Configuration GetConfiguration(string[] args) { var conf = new Configuration(); for (int x = 0; x < args.Length; x++) { bool consumedOption = false; if (args[x] == "-i") { conf.InputFile = args[x + 1]; consumedOption = true; } if (args[x] == "-o") { conf.OutputFile = args[x + 1]; consumedOption = true; } if (consumedOption) x++; } return conf; }
private static TextWriter GetOutputWriter(Configuration config) { if (!config.IsOutputFileSet) return Console.Out; return new StreamWriter(new FileStream(config.OutputFile, FileMode.Create, FileAccess.Write, FileShare.None)); }
private static TextReader GetInputReader(Configuration config) { if (!config.IsInputFileSet) return Console.In; return new StreamReader(new FileStream(config.InputFile, FileMode.Open, FileAccess.Read, FileShare.Read)); }