aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-22 13:28:13 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-22 13:28:13 +0300
commit5ed5ef7ef65731a9e509cb7a707722458da206d1 (patch)
treec5bbe5086113a629c7a7c365698a95c971904c9b /Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
parent34d7201f46c07a6311fcaa9df329ec22c5ebdb49 (diff)
downloadTango-5ed5ef7ef65731a9e509cb7a707722458da206d1.tar.gz
Tango-5ed5ef7ef65731a9e509cb7a707722458da206d1.zip
Working on FSE scripting.
Fixed issue with gradient generation using the color converter RGB only entry point for RGB and LAB brush stops.
Diffstat (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs')
-rw-r--r--Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
index 4b04270c1..665bd7ab1 100644
--- a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
+++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
@@ -3,15 +3,26 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+using Tango.Core.Helpers;
namespace Tango.Scripting.Basic
{
public class ReferenceAssembly
{
+ private static Dictionary<String, Assembly> _assembliesCache;
+
+ static ReferenceAssembly()
+ {
+ _assembliesCache = new Dictionary<string, Assembly>();
+ }
+
public String File { get; set; }
+ public Type HintType { get; set; }
+
[JsonIgnore]
public String Name
{
@@ -21,6 +32,7 @@ namespace Tango.Scripting.Basic
public static ReferenceAssembly FromType(Type type)
{
ReferenceAssembly reference = new ReferenceAssembly();
+ reference.HintType = type;
var assembly = type.Assembly;
reference.File = assembly.Location;
return reference;
@@ -30,5 +42,47 @@ namespace Tango.Scripting.Basic
{
return new ReferenceAssembly() { File = file };
}
+
+ public Assembly Load()
+ {
+ Assembly loaded = null;
+ if (!_assembliesCache.TryGetValue(Name, out loaded))
+ {
+ try
+ {
+ if (HintType != null)
+ {
+ loaded = HintType.Assembly;
+ }
+ else
+ {
+ loaded = Assembly.LoadFrom(File);
+ }
+
+ _assembliesCache.Add(Name, loaded);
+ }
+ catch
+ {
+ try
+ {
+ String dotNetPath = AssemblyHelper.GetAssemblyTargetFrameworkFolder(Assembly.GetExecutingAssembly());
+ String dotNetAsm = Path.Combine(dotNetPath, Name + ".dll");
+ loaded = Assembly.LoadFrom(dotNetAsm);
+ _assembliesCache.Add(Name, loaded);
+ }
+ catch (Exception ex)
+ {
+ throw new FileNotFoundException($"Could not load assembly '{Name}'. File not found.", ex);
+ }
+ }
+ }
+
+ return loaded;
+ }
+
+ public override string ToString()
+ {
+ return Name;
+ }
}
}