Skip to content

Commit

Permalink
Merge pull request #16 from SciSharp/master
Browse files Browse the repository at this point in the history
Pass example name from arguments.
  • Loading branch information
plkn committed Feb 22, 2019
2 parents 74f2b7f + 2be4a5d commit 61763e1
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 22 deletions.
11 changes: 11 additions & 0 deletions Examples/IExample.cs
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Examples
{
public interface IExample
{
void Run(string pythonExePath, string dasPlotPyPath);
}
}
4 changes: 2 additions & 2 deletions Examples/Plot2D/ExampleArс.cs
Expand Up @@ -8,12 +8,12 @@

namespace Examples.Plot2D
{
class ExampleArс
class ExampleArс : IExample
{
/// <summary>
/// Chart of sin
/// </summary>
public static void Run(string pythonExePath, string dasPlotPyPath)
public void Run(string pythonExePath, string dasPlotPyPath)
{
#region create test data

Expand Down
4 changes: 2 additions & 2 deletions Examples/Plot2D/ExampleHistogram.cs
Expand Up @@ -8,12 +8,12 @@

namespace Examples.Plot2D
{
class ExampleHistogram
class ExampleHistogram : IExample
{
/// <summary>
/// Chart of sin
/// </summary>
public static void Run(string pythonExePath, string dasPlotPyPath)
public void Run(string pythonExePath, string dasPlotPyPath)
{
#region create test data

Expand Down
4 changes: 2 additions & 2 deletions Examples/Plot2D/ExamplePoint2D.cs
Expand Up @@ -8,12 +8,12 @@

namespace Examples.Plot2D
{
class ExamplePoint2D
class ExamplePoint2D : IExample
{
/// <summary>
/// Chart of sin
/// </summary>
public static void Run(string pythonExePath, string dasPlotPyPath)
public void Run(string pythonExePath, string dasPlotPyPath)
{
// init engine with right paths
var matplotlibCs = new MatplotlibCS.MatplotlibCS(pythonExePath, dasPlotPyPath);
Expand Down
4 changes: 2 additions & 2 deletions Examples/Plot2D/ExampleSin.cs
Expand Up @@ -8,12 +8,12 @@

namespace Examples.Plot2D
{
class ExampleSin
class ExampleSin : IExample
{
/// <summary>
/// Chart of sin
/// </summary>
public static void Run(string pythonExePath, string dasPlotPyPath)
public void Run(string pythonExePath, string dasPlotPyPath)
{
#region create test data

Expand Down
4 changes: 2 additions & 2 deletions Examples/Plot2D/ExampleTimeAxis.cs
Expand Up @@ -8,12 +8,12 @@

namespace Examples.Plot2D
{
class ExampleTimeAxis
class ExampleTimeAxis : IExample
{
/// <summary>
/// Chart of sin
/// </summary>
public static void Run(string pythonExePath, string dasPlotPyPath)
public void Run(string pythonExePath, string dasPlotPyPath)
{
#region create test data

Expand Down
4 changes: 2 additions & 2 deletions Examples/Plot2D/ExampleVisibility.cs
Expand Up @@ -8,12 +8,12 @@

namespace Examples.Plot2D
{
class ExampleVisibility
class ExampleVisibility : IExample
{
/// <summary>
/// Chart of sin
/// </summary>
public static void Run(string pythonExePath, string dasPlotPyPath)
public void Run(string pythonExePath, string dasPlotPyPath)
{
// init engine with right paths
var matplotlibCs = new MatplotlibCS.MatplotlibCS(pythonExePath, dasPlotPyPath);
Expand Down
37 changes: 28 additions & 9 deletions Examples/Program.cs
@@ -1,5 +1,7 @@
using Examples.Plot2D;
using System;
using System.Linq;
using System.Reflection;

namespace Examples
{
Expand All @@ -20,22 +22,39 @@ class Program

static void Main(string[] args)
{
if (args.Length != 2)
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[0];
_matplotlibPyPath = args[1];
_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}");
}

//ExampleSin.Run(_pythonExePath, _matplotlibPyPath);
ExampleArс.Run(_pythonExePath, _matplotlibPyPath);
//ExampleVisibility.Run(_pythonExePath, _matplotlibPyPath);
//ExampleHistogram.Run(_pythonExePath, _matplotlibPyPath);
//ExampleTimeAxis.Run(_pythonExePath, _matplotlibPyPath);
//ExamplePoint2D.Run(_pythonExePath, _matplotlibPyPath);
Console.ReadLine();
}
}
}
3 changes: 2 additions & 1 deletion Examples/Properties/launchSettings.json
@@ -1,7 +1,8 @@
{
"profiles": {
"Examples": {
"commandName": "Project"
"commandName": "Project",
"commandLineArgs": "ExamplePoint2D python.exe tmp"
}
}
}

0 comments on commit 61763e1

Please sign in to comment.