Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkkirschner committed Dec 11, 2023
1 parent 6c0bede commit 02efa74
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions IronPythonExtension/IronPythonExtension.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using Dynamo.Extensions;
using Dynamo.Logging;
using Dynamo.PythonServices;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using Dynamo.Extensions;
using Dynamo.Logging;
using Dynamo.PythonServices;

namespace IronPythonExtension
{
Expand Down Expand Up @@ -63,12 +63,12 @@ public void Startup(StartupParams sp)
/// <param name="sp"></param>
public void Ready(ReadyParams sp)
{
var extraPath = Path.Combine(new FileInfo(Assembly.GetAssembly(typeof(IronPythonExtension)).Location).Directory.Parent.FullName, "extra");
var alc = new IsolatedPythoContext(Path.Combine(extraPath,"DSIronPython.dll"));
var dsiron = alc.LoadFromAssemblyName(new AssemblyName("DSIronPython"));
var extraPath = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.Parent.FullName, "extra");
var alc = new IsolatedPythonContext(Path.Combine(extraPath,"DSIronPython.dll"));
var dsIronAssem = alc.LoadFromAssemblyName(new AssemblyName("DSIronPython"));

//load the engine into Dynamo ourselves.
LoadPythonEngine(dsiron);
LoadPythonEngine(dsIronAssem);
}

/// <summary>
Expand All @@ -79,7 +79,7 @@ public void Shutdown()
// Do nothing for now
}

private void LoadPythonEngine(Assembly assembly)
private static void LoadPythonEngine(Assembly assembly)
{
if (assembly == null)
{
Expand Down Expand Up @@ -112,7 +112,7 @@ private void LoadPythonEngine(Assembly assembly)
throw new Exception($"Could not get a valid PythonEngine instance by calling the {eType.Name}.Instance method");
}

if (!PythonEngineManager.Instance.AvailableEngines.Any(x=>x.Name == engine.Name))
if (PythonEngineManager.Instance.AvailableEngines.All(x => x.Name != engine.Name))
{
PythonEngineManager.Instance.AvailableEngines.Add(engine);
}
Expand All @@ -123,11 +123,11 @@ private void LoadPythonEngine(Assembly assembly)
}
}
}
internal class IsolatedPythoContext : AssemblyLoadContext
internal class IsolatedPythonContext : AssemblyLoadContext
{
private AssemblyDependencyResolver resolver;

public IsolatedPythoContext(string libPath)
public IsolatedPythonContext(string libPath)
{
resolver = new AssemblyDependencyResolver(libPath);
}
Expand Down

0 comments on commit 02efa74

Please sign in to comment.