-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeLoadContext.cs
More file actions
36 lines (29 loc) · 923 Bytes
/
CodeLoadContext.cs
File metadata and controls
36 lines (29 loc) · 923 Bytes
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 Dotnet.Script.DependencyModel.Logging;
using System;
using System.Reflection;
using System.Runtime.Loader;
namespace Markdig.Extensions.Xmdl.CSharp;
internal sealed class CodeLoadContext : AssemblyLoadContext
{
private readonly AssemblyDependencyResolver resolver;
public CodeLoadContext(string name) : base(name: name, isCollectible: true)
{
}
public CodeLoadContext(string name, string path) : base(name: name, isCollectible: true)
{
resolver = new AssemblyDependencyResolver(path);
}
protected override Assembly Load(AssemblyName assemblyName)
{
string assemblyPath = resolver?.ResolveAssemblyToPath(assemblyName);
if (assemblyPath != null)
{
return LoadFromAssemblyPath(assemblyPath);
}
return null;
}
protected override nint LoadUnmanagedDll(string unmanagedDllName)
{
return 0;
}
}