mirror of
https://gitea.tendokyu.moe/Kayori/Medusa.net.git
synced 2026-09-28 17:58:10 +03:00
18 lines
529 B
C#
18 lines
529 B
C#
using System.Reflection;
|
|
using System.Runtime.Loader;
|
|
using Path = System.IO.Path;
|
|
|
|
namespace Server.Plugins;
|
|
|
|
public sealed class PluginLoadContext(string pluginAssemblyPath)
|
|
: AssemblyLoadContext(isCollectible: true)
|
|
{
|
|
private readonly AssemblyDependencyResolver _resolver = new(pluginAssemblyPath);
|
|
|
|
protected override Assembly? Load(AssemblyName assemblyName)
|
|
{
|
|
var path = _resolver.ResolveAssemblyToPath(assemblyName);
|
|
|
|
return path is not null ? LoadFromAssemblyPath(path) : null;
|
|
}
|
|
} |