Refactored getOpenSCADPath out to OpenSCADPathFinder

This commit is contained in:
Michael L Smith 2016-02-28 15:12:38 -08:00
parent 26f4d70876
commit da558ce75f
3 changed files with 32 additions and 18 deletions

View File

@ -48,6 +48,7 @@
<Compile Include="Files\IFileInvoker.cs" />
<Compile Include="Files\IFileWriter.cs" />
<Compile Include="Ids.cs" />
<Compile Include="OpenSCADPathFinder.cs" />
<Compile Include="Scripting\Binding.cs" />
<Compile Include="Scripting\Bindings.cs" />
<Compile Include="Scripting\IBindable.cs" />

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp
{
internal class OpenSCADPathFinder
{
private string[] possibleFilePaths = new string[]
{
@"C:\Program Files (x86)\OpenSCAD\openscad.exe",
@"C:\Program Files\OpenSCAD\openscad.exe"
};
internal string GetPath()
{
foreach (string path in possibleFilePaths)
{
if (File.Exists(path))
return path;
}
return null;
}
}
}

View File

@ -24,23 +24,6 @@ namespace OSCADSharp
/// Path to the OpenSCAD executable for file invocation
/// (Default value is set the default install directory on Windows)
/// </summary>
public static string OpenSCADPath = getOpenSCADPath();
private static string getOpenSCADPath()
{
string[] possibleFilePaths = new string[]
{
@"C:\Program Files (x86)\OpenSCAD\openscad.exe",
@"C:\Program Files\OpenSCAD\openscad.exe"
};
foreach (string path in possibleFilePaths)
{
if (File.Exists(path))
return path;
}
return null;
}
public static string OpenSCADPath = new OpenSCADPathFinder().GetPath();
}
}