-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (37 loc) · 1.3 KB
/
Program.cs
File metadata and controls
46 lines (37 loc) · 1.3 KB
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
using System;
using System.Linq;
namespace SharpBenchmark.Samples
{
class Program
{
static void Main(string[] args)
{
var allSamples = typeof(ISample).Assembly.GetTypes();
while (true)
{
Console.Write("Which sample would you like to run? (enter q to quit): ");
var input = Console.ReadLine();
if (input == "q" || input == null)
break;
var parts = input.Split(' ');
var sampleNum = 0;
if (!Int32.TryParse(parts[0], out sampleNum))
{
Console.WriteLine("Please enter an integer. Try again.");
continue;
}
// get the problem class based on the name
var problemType = allSamples.FirstOrDefault(x => x.Name == "Sample" + sampleNum);
if (problemType == null)
{
Console.WriteLine("Invalid sample number. Try again.");
continue;
}
var sample = (ISample)Activator.CreateInstance(problemType);
var tmp = parts.ToList();
tmp.RemoveAt(0);
sample.Execute(tmp.ToArray());
}
}
}
}