Skip to content

Commit

Permalink
static constructor program
Browse files Browse the repository at this point in the history
  • Loading branch information
mstama committed Jul 6, 2017
1 parent ff77410 commit cb72834
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Merchant/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ namespace Merchant
{
internal static class Program
{
private static ICommandParser _parser;
private static readonly ICommandParser _parser;
private static readonly Queue<Command> _retry = new Queue<Command>();
private static ICommandVisitor _visitor;
private static readonly ICommandVisitor _visitor;

// Composition root
private static void Init()
static Program()
{
_visitor = new CommandVisitor(new RateCalculator(), new MapTextConverter(), new RomanNumberConverter());
_parser = new CommandRegexParser();
}

private static void Main(string[] args)
{
Init();
if (args.Length == 0)
{
Console.WriteLine("Input file required!");
Expand All @@ -33,9 +32,8 @@ private static void Main(string[] args)
string filePath = args[0];
if (!File.Exists(filePath)) { Console.WriteLine("File does not exist!"); }
Console.WriteLine("Processing file {0}.", args[0]);
var lines = File.ReadLines(filePath);

foreach (var line in lines)
foreach (var line in File.ReadLines(filePath))
{
var command = _parser.Parse(line);
try
Expand Down

0 comments on commit cb72834

Please sign in to comment.