28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
using System.Runtime.Loader;
|
|
using AcDream.Plugin.Abstractions;
|
|
using AcDream.Plugin.Abstractions.Rendering;
|
|
|
|
namespace AcDream.Core.Plugins;
|
|
|
|
/// <summary>
|
|
/// Outcome of a plugin load attempt.
|
|
/// <para>On success, at least one of <see cref="Plugin"/> or
|
|
/// <see cref="RenderPackPlugin"/> is instantiated, <see cref="LoadContext"/>
|
|
/// owns the assembly, and <see cref="Error"/> is null.</para>
|
|
/// <para>On failure, <see cref="Error"/> describes what went wrong. A partial
|
|
/// entry-point instances and/or <see cref="LoadContext"/> may still be present;
|
|
/// the caller owns their cleanup. The loader never requests collectible unload
|
|
/// itself because the session must first roll back host registrations.</para>
|
|
/// </summary>
|
|
public sealed record LoadedPlugin(
|
|
PluginManifest Manifest,
|
|
IAcDreamPlugin? Plugin,
|
|
AssemblyLoadContext? LoadContext,
|
|
Exception? Error,
|
|
IRenderPackPlugin? RenderPackPlugin = null)
|
|
{
|
|
public bool Success =>
|
|
(Plugin is not null || RenderPackPlugin is not null)
|
|
&& LoadContext is not null
|
|
&& Error is null;
|
|
}
|