aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d93733d4625ad329b2ba8237f445364b3f.tar.gz
Tango-00a491d93733d4625ad329b2ba8237f445364b3f.zip
merge
Diffstat (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs')
-rw-r--r--Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs88
1 files changed, 0 insertions, 88 deletions
diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
deleted file mode 100644
index 665bd7ab1..000000000
--- a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/ReferenceAssembly.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using Newtonsoft.Json;
-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
- {
- get { return Path.GetFileNameWithoutExtension(File); }
- }
-
- public static ReferenceAssembly FromType(Type type)
- {
- ReferenceAssembly reference = new ReferenceAssembly();
- reference.HintType = type;
- var assembly = type.Assembly;
- reference.File = assembly.Location;
- return reference;
- }
-
- public static ReferenceAssembly FromFile(String file)
- {
- 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;
- }
- }
-}