mirror of
https://gitea.tendokyu.moe/Kayori/Medusa.net.git
synced 2026-09-26 00:07:57 +03:00
- Refactor handler dispatch to use a parsed GameModel instead of raw model strings (Handler.cs, HandlerService.cs, new GameModel.cs) - Add a Unity asset-extraction subsystem (Abstractions/Extractors/Unity) - Add WriteEventLogHandler, XrpcDouble serialization type - Rename EaCoin*Handler -> *EaCoinHandler for naming consistency - Add PIN/username update and forgot/reset password flows, with a console-logging IEmailSender until real email is wired up - Add a settings page and a theming pass (theme tokens, tailwind config) - Add plugin nav/route/UI-manifest frontend types
36 lines
1.4 KiB
C#
36 lines
1.4 KiB
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);
|
|
|
|
public string AssemblyPath => pluginAssemblyPath;
|
|
|
|
// Host-shared contract assemblies. Plugins may ship their own copies for build-time tooling
|
|
// (e.g. `dotnet ef migrations add`), but at runtime these must resolve to the host's ALC
|
|
// so that types like IMedusaPlugin and AssetTypeValueField have a single identity.
|
|
// Without this, `t.GetInterfaces().Contains(typeof(IMedusaPlugin))` silently fails.
|
|
private static readonly HashSet<string> SharedAssemblyNames = new(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
"Abstractions",
|
|
"AssetsTools.NET",
|
|
"AssetsTools.NET.Texture"
|
|
};
|
|
|
|
protected override Assembly? Load(AssemblyName assemblyName)
|
|
{
|
|
if (assemblyName.Name is not null && SharedAssemblyNames.Contains(assemblyName.Name))
|
|
return null; // fall through to the Default AssemblyLoadContext
|
|
|
|
var path = _resolver.ResolveAssemblyToPath(assemblyName);
|
|
if (path is null) return null;
|
|
|
|
using var stream = new MemoryStream(File.ReadAllBytes(path));
|
|
return LoadFromStream(stream);
|
|
}
|
|
} |