Skip to content

Commit

Permalink
fix: multi entry-point
Browse files Browse the repository at this point in the history
  • Loading branch information
LazuliKao committed Jul 22, 2023
1 parent b632606 commit cbcdff7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Loader;

internal static class PluginManager
{
public static List<(AssemblyLoadContext ctx, IPlugin plugin)> PluginContexts { get; }
public static List<(AssemblyLoadContext ctx, List<IPlugin> plugin)> PluginContexts { get; }

static PluginManager()
{
Expand All @@ -18,13 +18,15 @@ public static bool LoadPlugin(string path)
AssemblyLoadContext loadContext = new(path);
Assembly assembly = loadContext.LoadFromAssemblyPath(path);
var success = false;
var plugins = new List<IPlugin>();
foreach (var entryPoint in assembly.GetCustomAttributes<EntryPointAttributeBase>())
{
var plugin = entryPoint.CreateInstance();
plugin.Initialize();
PluginContexts.Add((loadContext, plugin));
success = true;
plugins.Add(plugin);
}
PluginContexts.Add((loadContext, plugins));
return success;
}
}

0 comments on commit cbcdff7

Please sign in to comment.