-
Notifications
You must be signed in to change notification settings - Fork 39
/
Program.cs
60 lines (50 loc) · 1.72 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
60
using Examples.Plot2D;
using System;
using System.Linq;
using System.Reflection;
namespace Examples
{
/// <summary>
/// Sample programm which creates several charts and save them in png
/// </summary>
class Program
{
/// <summary>
/// Path to python.exe, must be initialized in Main
/// </summary>
private static string _pythonExePath;
/// <summary>
/// Path to dasPlot.py, script which finally builds plots
/// </summary>
private static string _matplotlibPyPath;
static void Main(string[] args)
{
if (args.Length != 3)
{
Console.WriteLine("You must specify path to python.exe and to matplotlib_cs.py in command line arguments");
Console.ReadKey();
return;
}
_pythonExePath = args[1];
_matplotlibPyPath = args[2];
var assembly = Assembly.GetEntryAssembly();
foreach (Type type in assembly.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IExample))))
{
if (args.Length > 0 && !args.Contains(type.Name))
continue;
Console.WriteLine($"{DateTime.UtcNow} Starting {type.Name}");
var example = (IExample)Activator.CreateInstance(type);
try
{
example.Run(_pythonExePath, _matplotlibPyPath);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Console.WriteLine($"{DateTime.UtcNow} Completed {type.Name}");
}
Console.ReadLine();
}
}
}