forked from idg10/prog-cs-8-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
36 lines (31 loc) · 1014 Bytes
/
Program.cs
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
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using HostApp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PlugInInterface;
namespace PlugIns
{
class Program
{
static void Main()
{
string plugInDllPath = Path.Combine(
Path.GetDirectoryName(typeof(Program).Assembly.Location),
"MyPlugIn.dll");
Assembly[] plugInApiAssemblies =
{
typeof(IPlugIn).Assembly,
typeof(JsonReader).Assembly
};
var plugInAssemblyNames = new HashSet<string>(
plugInApiAssemblies.Select(a => a.GetName().Name));
var ctx = new PlugInLoadContext(plugInDllPath, plugInAssemblyNames);
Assembly plugInAssembly = ctx.LoadFromAssemblyPath(plugInDllPath);
var pi = (IPlugIn)plugInAssembly.CreateInstance("MyPlugIn.MyPlugInType");
pi.Foo(new JObject());
}
}
}