-
Notifications
You must be signed in to change notification settings - Fork 13
/
PluginSystem.pas
40 lines (32 loc) · 1008 Bytes
/
PluginSystem.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
namespace RemObjects.Train;
interface
type
PluginSystem = public static class
private
class var TrainLib, ScriptLib: System.Reflection.&Assembly;
class method Resolve(o: Object; args: ResolveEventArgs): System.Reflection.&Assembly;
public
class constructor;
class method Load(fn: String);
end;
implementation
class method PluginSystem.Load(fn: String);
begin
System.Reflection.Assembly.LoadFile(fn);
end;
class constructor PluginSystem;
begin
TrainLib := typeOf(PluginSystem).Assembly;
ScriptLib := typeOf(RemObjects.Script.EcmaScript.EcmaScriptArrayObject).Assembly;
AppDomain.CurrentDomain.AssemblyResolve += Resolve;
end;
class method PluginSystem.Resolve(o: Object; args: ResolveEventArgs): System.Reflection.&Assembly;
begin
var name := args.Name.Split(',')[0].Trim.ToLowerInvariant;
if name = 'remobjects.script' then
exit ScriptLib;
if name = 'remobjects.train' then
exit TrainLib;
exit nil;
end;
end.