mirror of
https://github.com/denglihong2007/CRSim
synced 2026-06-23 10:25:41 +08:00
22 lines
581 B
C#
22 lines
581 B
C#
using System.Reflection;
|
|
using System.Runtime.Loader;
|
|
|
|
namespace CRSim.Core.Utils
|
|
{
|
|
internal class PluginLoadContext(string pluginPath) : AssemblyLoadContext
|
|
{
|
|
private readonly AssemblyDependencyResolver _resolver = new(pluginPath);
|
|
|
|
protected override Assembly Load(AssemblyName assemblyName)
|
|
{
|
|
string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
|
|
if (assemblyPath != null)
|
|
{
|
|
return LoadFromAssemblyPath(assemblyPath);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|