/
Program.cs
59 lines (51 loc) · 1.76 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using BRIT.Calculator.Entities;
using BRIT.Calculator.Framework;
namespace BRIT.Calculator
{
class Program
{
static void Main(string[] args)
{
try
{
//Pass the file path and file name to the StreamReader constructor
StreamReader sr = new StreamReader("C:\\SampleInstructions.txt");
NinjectFactory ninjectFactory = new NinjectFactory();
var processor = ninjectFactory.GetInstructionProcessor(new char[0]);
String line;
Instruction instruction;
List<Instruction> instructions = new List<Instruction>();
//Read the first line of text
line = sr.ReadLine();
//Continue to read until you reach end of file
while (line != null)
{
instruction = new Instruction();
instruction = processor.GetInstruction(line);
instructions.Add(instruction);
//Read the next line
line = sr.ReadLine();
}
decimal result = processor.ProcessInstructions(instructions);
//close the file
sr.Close();
Console.WriteLine(result);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
finally
{
Console.WriteLine("Executing finally block.");
}
}
}
}